function biz_updateChipsNo(&$chips)
{
    //从项目配置获取前缀配置
    $project = biz_getProject($chips['projguid']);
    $set = biz_unserializer($project, 'finance');
    $prefix = '';
    if (!empty($set['ChipsPre'])) {
        $prefix = $set['ChipsPre'];
    }
    $key = 'chipsNo_' . $project['projguid'];
    if (memcached_addKey($key)) {
        $index = pdo_fetchcolumn('select count(*) from ims_chips where printdate>:time and projguid=:projguid', array(':time' => strtotime(date('Y-m-d')), ':projguid' => $chips['projguid']));
        $no = $prefix . date('ymd', TIMESTAMP) . sprintf('%04d', $index + 1);
        $chips['ChipsNo'] = $no;
        $chips['printdate'] = TIMESTAMP;
        pdo_update('chips', array('ChipsNo' => $no, 'printdate' => TIMESTAMP), array('id' => $chips['id']));
        memcached_delete($key);
    }
}
function biz_mem_clearProject($project = '')
{
    if (empty($project)) {
        global $_W;
        $project = $_W['project'];
    }
    memcached_delete('P_' . $project['id']);
    memcached_delete('P_' . $project['projguid']);
}
Exemple #3
0
            memcached_delete('Add' . $key);
            $res['ok'] = true;
            $res['token'] = $token;
        } else {
            $res['msg'] = '无法增加cache数据';
        }
    } else {
        $res['msg'] = '此项目已有下载未完成,请等5分钟再试';
    }
    returnJson($res);
}
if ($func == 'release_token') {
    $token = $_GPC['token'];
    $data = memcached_get('sync_t_' . $token);
    memcached_delete('sync_' . $data['guid']);
    memcached_delete('sync_t_' . $token);
}
//获取数据接口
if ($func == 'get_data') {
    $token = $_GPC['token'];
    $data = memcached_get('sync_t_' . $token);
    $type = $_GPC['type'];
    $enable = !empty($data) && !empty($data['guid']);
    //$enable=$enable && ($data['ip']==CLIENT_IP);
    $list = array('project', 'build', 'room', 'chips', 'user');
    if ($enable && in_array($type, $list)) {
        $call = 'download_' . $type;
        $res['ok'] = true;
        $res['data'] = $call($data['guid']);
    } else {
        $res['msg'] = '无效调用';
Exemple #4
0
/**
 *获得签到全局表信息
 * 自动增加组
 * @param $key 认筹单二维码key
 * @param $project 项目
 */
function App_Sign_getGroup($key, $project)
{
    $res = array('signed' => false, 'msg' => '');
    $pid = $project['id'];
    //查询是否已有分配的签到
    $sign = biz_getSignInfoByQrcode($key, $pid);
    $chips = biz_getChipsByQrcode($key);
    if (empty($chips)) {
        $res['msg'] = '无效认筹单';
        return $res;
    }
    if (empty($sign) || $sign['preset'] == 1) {
        if ($chips['projguid'] != $project['projguid']) {
            $res['msg'] = '认筹单所属非当前项目';
            return $res;
        }
        //处理已签到信息
        if ($chips['singed'] == 1) {
            $res['msg'] = '认筹单已签到';
            return $res;
        }
    }
    if (isset($chips) || !$sign['signed']) {
        $cachekey = 'lock_sign_' . $pid;
        //写入签到信息
        if (memcached_addKey($cachekey, 30)) {
            if (empty($sign)) {
                $info = getGlobalSign($project);
                $sign = biz_insertSignInfo($chips, $info['group']['dispnum'], $pid, false, true);
                if (!empty($sign)) {
                    // $sign = biz_getSignInfoByQrcode($key, $pid);
                    $res['signed'] = true;
                    $res['group'] = $info['group']['dispnum'];
                }
            } else {
                if (empty($sign['signed'])) {
                    $update['signed'] = 1;
                    $update['signtime'] = TIMESTAMP;
                    pdo_update('sign', $update, array('id' => $sign['id']));
                    unset($update);
                    $sign['signed'] = 1;
                    $sign['signtime'] = TIMESTAMP;
                    $res['signed'] = true;
                    $res['group'] = $sign['gid'];
                }
            }
            if (!empty($sign)) {
                //更新对应组信息
                Sign_updateGroup($sign, true);
            }
            if ($res['signed']) {
                //签到记录组号
                pdo_update('chips', array('signed' => $sign['gid']), array('id' => $chips['id']));
                db_updateChipsStatus($chips['id'], 4);
            }
            memcached_delete($cachekey);
        }
    } else {
        $res['signed'] = !empty($sign['signed']);
    }
    $res['sign'] = $sign;
    return $res;
}
Exemple #5
0
 public function doWebSet()
 {
     global $_W, $_GPC;
     $op = $_GPC['op'];
     $this->CheckRight('set');
     //检查项目状态,是否允许设置
     $project = db_getProject($_W['pid'], false, false);
     if (empty($project)) {
         //|| !empty($project['status'])
         if ($_W['isajax']) {
             echo '无效的项目数据或当前项目不允许设置!';
             exit;
         } else {
             message('无效的项目数据或当前项目不允许设置!', $this->createWebUrl('manage'));
         }
     }
     $url = $this->createWebUrl('set', array('op' => $op));
     if ($op == 'discount') {
         $discount = db_getDiscount($project['projguid'], 'DiscntGUID');
         $payform = db_getPayForm($project['projguid'], 'PayFormGUID');
         foreach ($payform as &$p) {
             if ($p['DisCount']) {
                 $p['title'] = $p['PayformName'] . "[{$p['DisCount']}%]";
             }
             if ($p['PreferentialPrice'] > 0) {
                 $p['title'] = $p['PayformName'] . "[-{$p['PreferentialPrice']}¥]";
             }
         }
         unset($p);
         $set = biz_unserializer($project, 'payform');
         if (empty($set)) {
             $set = array('pay_id' => '');
         } else {
             if (count($set['pay_id']) > 0) {
                 foreach ($discount as $k => $v) {
                     $discount[$k]['select'] = in_array($k, $set['dis_id']);
                 }
             }
         }
         if ($_W['isajax']) {
             include $this->template('discountSet');
             exit;
         }
         if ($_W['token'] == $_GPC['token']) {
             $pay_id = trim($_GPC['payform']);
             $calc = array('paydiscount' => 1.0, 'decmoney' => 0, 'discount' => 1.0);
             if (!empty($pay_id) && isset($payform[$pay_id])) {
                 $set['pay_id'] = $pay_id;
                 $set['Payform'] = $payform[$pay_id];
                 $set['title'] = $payform[$pay_id]['title'];
                 $set['details'] = db_getPaydetail($pay_id);
             }
             unset($set['dis_id']);
             foreach ($_GPC['discount'] as $d) {
                 if (isset($discount[$d])) {
                     $set['dis_id'][] = $d;
                 }
             }
             $calc = biz_getRoomPriceCalc($set, $discount, $payform);
             $set['calc'] = $calc;
             $tip = round($calc['discount'] * 100, 2);
             $set['discount'] = "减免{$calc['dec_money']},折扣{$tip}%";
             $data = array('payform' => iserializer($set));
             pdo_update('project', $data, array('id' => $_W['pid']));
             biz_mem_clearProject();
             $rooms = db_getRooms($_W['project']['projguid']);
             foreach ($rooms as $r) {
                 if (in_array($r['Status'], array('待售', '销控'))) {
                     biz_calcRoomPrice($r, $calc, true);
                 }
                 //calc_payorder($r,true);
             }
             message('数据已设置', $this->createWebUrl('manage'));
         }
     }
     if ($op == 'invoice') {
         load()->web('print');
         $set = biz_unserializer($project, 'finance');
         if (empty($set['prepay'])) {
             $prepay = $set;
         } else {
             $prepay = $set['prepay'];
         }
         $order = $set['order'];
         $prefix = $set['Prefix'];
         if ($_W['isajax']) {
             include $this->template('invoiceSet');
             exit;
         }
         if ($_W['token'] == $_GPC['token']) {
             $getInvoInfo = function ($set) use($project) {
                 $set['BatchNo'] = trim($set['BatchNo']);
                 $set['Prefix'] = trim($set['Prefix']);
                 $invo = biz_getInvoiceByBatchNo($set['BatchNo'], $set['Prefix'], $project);
                 $config = array('BatchNo' => $set['BatchNo'], 'Prefix' => $set['Prefix']);
                 if (!empty($invo)) {
                     $config['InvoGUID'] = $invo['InvoGUID'];
                 }
                 return $config;
             };
             $set = array();
             $set['prepay'] = $getInvoInfo($_GPC['prepay']);
             $set['order'] = $getInvoInfo($_GPC['order']);
             $set['Prefix'] = trim($_GPC['Prefix']);
             $set['ChipsPre'] = trim($_GPC['ChipsPre']);
             $data = array('finance' => iserializer($set));
             pdo_update('project', $data, array('id' => $_W['pid']));
             biz_mem_clearProject($project);
             message('数据已设置', $this->createWebUrl('manage'));
         }
     }
     if ($op == 'sign') {
         $set = biz_unserializer($project, 'signset');
         if (empty($set)) {
             $set = array('num' => 10, 'max' => 1);
         }
         if ($_W['isajax']) {
             include $this->template('signSet');
             exit;
         }
         if ($_W['token'] == $_GPC['token']) {
             $set = array('num' => intval($_GPC['num']), 'max' => intval($_GPC['max']));
             if ($set['num'] <= 0) {
                 $set['num'] = 10;
             }
             if ($set['max'] <= 0) {
                 $set['max'] = 1;
             }
             //只能一组
             $set['max'] = 1;
             $data = array('signset' => iserializer($set));
             pdo_update('project', $data, array('id' => $_W['pid']));
             if ($_GPC['clear']) {
                 pdo_update('sign', array('signed' => 0), array('pid' => $_W['pid']));
                 pdo_update('call_group', array('called' => 0), array('pid' => $_W['pid']));
                 //pdo_update('p_room',array('selectroom'=>0))
                 memcached_delete('global_sign_' . $project['id']);
             }
             biz_mem_clearProject($project);
             message('数据已设置', $this->createWebUrl('manage'));
         }
     }
     if ($op == 'project') {
         $status = biz_getDictionary('projstatus');
         //删除创建默认状态
         unset($status[0]);
         $set = biz_unserializer($project, 'sync');
         if ($_W['isajax']) {
             include $this->template('projSet');
             exit;
         }
         if ($_W['token'] == $_GPC['token']) {
             $selStatus = intval($_GPC['status']);
             $set = array('client' => trim($_GPC['client']));
             $data = array('status' => $selStatus, 'sync' => iserializer($set));
             pdo_update('project', $data, array('id' => $project['id']));
             biz_mem_clearProject($project);
             message('数据已设置', $this->createWebUrl('manage'));
         }
     }
     if ($op == 'build') {
         $set = biz_unserializer($project, 'builds');
         if (empty($set['timeout'])) {
             $set['timeout'] = 30;
         }
         $builds = db_getBuilds($_W['project']['projguid'], 'BldGUID');
         if ($_W['isajax']) {
             include $this->template('buildSet');
             exit;
         }
         if ($_W['token'] == $_GPC['token']) {
             $bids = $_GPC['m_ids'];
             $timeout = intval($_GPC['timeout']);
             if ($timeout < 0 || $timeout > 300) {
                 $timeout = 30;
             }
             //统计房间数量
             // 更新
             pdo_update('p_building', array('status' => '0'), array('ProjGUID' => $project['projguid']));
             $keys = array_keys($builds);
             foreach ($bids as $bldGuid) {
                 if (in_array($bldGuid, $keys)) {
                     pdo_update('p_building', array('status' => '1'), array('BldGUID' => $bldGuid));
                 }
             }
             $sql = 'SELECT count(*) as cnt FROM ims_p_room ';
             $sql .= ' a INNER JOIN ims_p_building b ON a.BldGUID = b.BldGUID ';
             $sql .= ' WHERE  b.`Status`=1 and b.ProjGUID=:projguid';
             $cnt = pdo_fetchcolumn($sql, array(':projguid' => $project['projguid']));
             $set = array('build' => $bids, 'timeout' => $timeout, 'roomnum' => $cnt);
             $data = array('builds' => iserializer($set));
             pdo_update('project', $data, array('id' => $_W['pid']));
             biz_mem_clearProject();
             message('数据已设置', $this->createWebUrl('manage'));
         }
     }
     if ($op == 'bank') {
         $banks = biz_getBanks($_W['project']['BUGUID']);
         $bk = empty($project['bank']) ? array() : iunserializer($project['bank']);
         if ($_W['isajax']) {
             include $this->template('bankSet');
             exit;
         }
         if ($_W['token'] == $_GPC['token']) {
             $bankid = $_GPC['bank'];
             $prebank = db_getPreBank($bankid);
             $data = array('bank' => iserializer($prebank));
             pdo_update('project', $data, array('id' => $_W['pid']));
             biz_mem_clearProject($project);
             message('数据已设置', $this->createWebUrl('manage'));
         }
     }
 }