function index($ctx) { $page = $_GET['page'] ? intval($_GET['page']) : 0; $size = $_GET['size'] ? intval($_GET['size']) : self::PAGE_SIZE; $ctx->page = $page; $ctx->size = $size; $wx_openid = $_GET['wx_openid'] ? htmlspecialchars($_GET['wx_openid']) : ''; $status = (string) $_GET['status'] !== '' ? htmlspecialchars($_GET['status']) : ''; $wx_id = $_GET['wx_id'] !== '' ? htmlspecialchars($_GET['wx_id']) : ''; $source = $_GET['source'] !== '' ? htmlspecialchars($_GET['source']) : ''; $ctx->status = $status; $ctx->wx_id = $wx_id; $ctx->source = $source; $ctx->wx_openid = $wx_openid; $where = 1; if ($status !== '') { $status = intval($status); $where .= " and status = '{$status}'"; } if ($source !== '') { $where .= " and source = '{$source}'"; } if ($wx_openid) { $where .= " and wx_openid = '{$wx_openid}'"; } if ($wx_id) { $where .= " and wx_id = '{$wx_id}'"; } $ds = WxOpenid::paginate($page, $size, $where, 'id desc'); $ctx->ds = $ds; }
private function unsubscribe($xml) { $from = $xml->FromUserName; $to = $xml->ToUserName; $connect = WxConnect::get_by('wx_openid', $from); if ($connect) { $connect->update(array('wx_subscribe' => WxConnect::WX_UNSUBSCRIBED, 'prj_subscribe' => WxConnect::PRJ_UNSUBSCRIBED)); } /* START 增加逻辑,订阅后,尝试向wx_openids插入 add@2015-04-20 21:49:12 */ try { $uid = isset($connect->user_id) ? $connect->user_id : ''; $uid_txt = $uid ? "用户id {$uid}" : ''; $tmp_where = "wx_openid = '{$from}' and wx_id = '{$to}'"; $wx_account_info = WxAccount::get_by('wx_id', $to); $wx_openid_info = WxOpenid::find_one($tmp_where); if ($wx_openid_info && $wx_openid_info->status == WxOpenid::STATUS_YES) { $attrs = array('status' => WxOpenid::STATUS_NO); $ret = $wx_openid_info->update($attrs); Logger::info("粉丝取消关注事件, 微信订阅服务号处理, 更新微信粉丝openid状态为[未关注], 微信openid : {$from} ,服务号微信id {$to} {$uid_txt}"); } } catch (Exception $e) { Logger::error("粉丝取消关注事件, 微信订阅服务号处理, 处理微信粉丝openid发生错误, 微信openid : {$from} ,服务号微信id {$to} {$uid_txt} 异常信息 - " . $e); } /* -- END -- */ Logger::info($connect->user_id . "取消关注微信公众号"); }