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); } }
/** *获得签到全局表信息 * 自动增加组 * @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; }
/** * 通过id获得楼盘数据 * 查询结果反序列化产品及房型 * @param $id * @param $isGuid id是否为GUID * @param $unzip 是否解压属性 */ function biz_getProject($id, $isGuid = true, $unzip = false) { $key = 'P_' . $id; $info = cache()->get($key); if (empty($info)) { if (memcached_addKey('Add_' . $key)) { $info = db_getProject($id, $isGuid, $unzip); memcached_set($key, $info); memcached_delete('Add_' . $key); } } return $info; }
load()->web('dbapi'); $func = strtolower($_GPC['func']); $res = array('ok' => false, 'msg' => ''); //检查项目授权,是否允许项目传输 if ($func == 'get_token') { //检查是否存在token? $guid = trim($_GPC['guid']); $key = 'sync_' . $guid; $token = memcached_get($key); if ($token == '') { $project = db_getProject($guid, true); if (empty($project)) { $res['msg'] = '无效的参数'; returnJson($res); } if (memcached_addKey('Add' . $key)) { $data = array('guid' => $guid, 'ip' => CLIENT_IP); $token = GUID(); memcached_set($key, $token, 300); memcached_set('sync_t_' . $token, $data, 300); memcached_delete('Add' . $key); $res['ok'] = true; $res['token'] = $token; } else { $res['msg'] = '无法增加cache数据'; } } else { $res['msg'] = '此项目已有下载未完成,请等5分钟再试'; } returnJson($res); }