/** * 当用户第一次关注公众号的时候,进行数据库插入操作 * @param referer 0 为搜索关注,1 为二维码关注 * @param type 二维码类型,1 为临时二维码,2为永久 */ public function weixin_subscribe($openid, $referer = 0, $sell_id = 0) { $sqlUser = new sql_userMod(); $res = $sqlUser->get_user_openid($openid); if ($res) { $sqlUser->set_user_subscribe($res['p_id'], $res['sub_time'] + 1); } else { $r = connectRedis($this->config['RD_HOST'], $this->config['RD_PORT'], $this->config['RD_DB']); $token = $r->get('token'); $wx_res = Weixin::get_user_info($token, $openid); if ($wx_res) { $res = $sqlUser->add_user_subscribe($wx_res, $referer, str_replace('sell_id', '', $sell_id)); dump($res); } } }
public function user() { $sqlUser = new sql_userMod(); $school = $this->in_get('sc', 0, 1, True); $cid = $this->in_get('cid', 0, 1); $ex_d = $this->in_get('ex_d', date('Y-m-d'), 2); $pr_d = $this->in_get('pr_d', date('Y-m-d', strtotime('+1 day')), 2); $url = preg_replace("/&p=\\d+/", '', $_SERVER['REQUEST_URI']); $url .= '&p={page}'; $url = str_replace('user&p', 'user?p', $url); $res = $sqlUser->get_user_super($url, $school, $cid, $ex_d, $pr_d); if (!$res) { echo '没有该品牌的订水情况'; $res = array('info' => '', 'page' => ''); } $this->assign('o_info', $res['info']); $this->assign('page', $res['page']); $this->display('user_list'); }