$is_reged = cloud_get_field('mobile', 'customers', " mobile = {$_POST['mobile']}"); if (empty($is_reged)) { $openid = $_POST['openid']; $realname = $_POST['realname']; $sex = $_POST['sex'] == 0 ? 2 : $_POST['sex']; //$province_txt= $_POST['province_txt']; //$city_txt = $_POST['city_txt']; $mobile = $_POST['mobile']; $back_url = $_POST['back_url']; $createtime = time(); $partner_id = cloud_get_field('partner_id', 'customers_from', "openid = '{$openid}'"); $number = 'M' . date('YmdHis') . randStr(6); //echo $field = "`number`,`partner_id`,`realname`,`sex`,`createtime`,`mobile`"; $value = "'{$number}','{$partner_id}','{$realname}','{$sex}','{$createtime}','{$mobile}'"; if (cloud_insert('customers', $field, $value)) { $res = array('flag' => 1); updateCustomerCount($partner_id); } } //http://cloud.net:8083/plus/hhr_customers.php } die(json_encode($res)); function updateCustomerCount($partner_id) { $customer_count = cloud_get_field('customer_count', 'partners', "id = '{$partner_id}'"); if (empty($customer_count)) { $customers = cloud_get_row('count(*) as count', 'customers', 'partner_id = ' . $partner_id); if (!cloud_update('partners', "customer_count ='{$customers['count']}'", 'id = ' . $partner_id)) { echo "error1"; }
$type = dirname($url_data['path']) == '/goods' ? 2 : 1; //2对应是goods,1对应是活动 $pid = $type == 2 ? get_query('gid', $url_data['query']) : get_query('aid', $url_data['query']); //判断是否浏览过 $is_looked = cloud_get_field('id', 'partner_share_click_record', 'openid = \'' . $openid . '\' AND pid = ' . $pid . ' AND type = ' . $type); if (empty($is_looked)) { //判断是否已经是其他人的粉丝 if (!cloud_get_field('id', 'customers_from', "openid = '{$openid}'")) { //添加用户粉丝判断 if (!cloud_insert('customers_from', 'openid,partner_id,type,time', "'{$openid}','{$partner_id}',2,'{$time}'")) { echo "error"; exti; } } //添加浏览记录 if (!cloud_insert('partner_share_click_record', 'share_id,pid,type,openid,partner_id,back_url,time', "'{$share_id}','{$pid}','{$type}','{$openid}','{$partner_id}','{$back_url}','{$time}'")) { echo "error 2"; exit; } } //echo $back_url;exit; //echo "succese"; header('location:' . $back_url); } else { //echo "您访问的页面出错";exit; $back_url = 'http://m.meilala.net/activites/'; header('location:' . $back_url); } //http://cloud.net:8083/plus/hhr_customers.php //http://cloud.net:8083/plus/hhr_share.php?o=oGZz6s3e_T0W0embYQ6zRH0ZiRXQ&u=http://m.meilala.net/goods/goods_detail.php?gid=151 } else {
require_once '../inc/common_hhr.php'; $share_id = $_POST['share_id']; $type = $_POST['type']; $partner_id = $_POST['partner_id']; $time = time(); $share_url = cloud_get_field('redirect_link', 'partner_message_tips', 'id = ' . $share_id); if (!empty($share_url)) { $have_record = cloud_get_field('id', 'partner_share_record', "partner_id = '{$partner_id}' AND share_id = '{$share_id}' AND type = '{$type}'"); if (!empty($have_record)) { if (cloud_update('partner_share_record', 'share_num = share_num+1,time = ' . $time, "id = '{$have_record}'")) { $res = array('flag' => 1); } } else { $field = "share_id,type,partner_id,share_url,share_num,time"; $value = "'{$share_id}','{$type}','{$partner_id}','{$share_url}','1','{$time}'"; if (cloud_insert('partner_share_record', $field, $value)) { $res = array('flag' => 1); } } } } //http://m.meilala.net/plus/hhr_share_record.php //cloud.net:8083/plus/hhr_share_record.php //share_id=298&partner_id=74&type=1 } die(json_encode($res)); function get_query($item, $params) { $paramsArr = explode('&', $params); foreach ($paramsArr as $k => $v) { $a = explode('=', $v);