load->library('session'); $this->load->_model('Model_customerxw','customerxw'); $this->load->_model('Model_typeclass','typeclass'); $this->load->_model('Model_shop','shop'); $this->load->_model('Model_country','country'); $this->load->_model('Model_express','express'); $this->load->_model('Model_fullorder','fullorder'); $this->load->_model('Model_fullorderxw','fullorderxw'); $this->load->_model('Model_excel','excel'); $this->load->_model('Model_whlabel','whlabel'); $this->load->_model('Model_warehouse','warehouse'); $this->load->_model('Model_specialstock','specialstock'); $this->load->_model('Model_ck','ck'); $this->load->_model('Model_weight','weight'); $this->load->_model('Model_pay','pay'); $this->load->_model('Model_setting','setting'); $this->load->_model('Model_classid','classid'); $this->load->_model('Model_apiyy','apiyy'); $this->load->_model('Model_apiyy','apiyy'); $this->load->_model('Model_whlabel_fc','whlabel_fc'); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if($arg == 'add')//添加 { $this->_add(); } else if($arg == 'edit')//修改 { $this->_edit($arg_array); } else if($arg == 'del')//黑名单 { $this->_del(); } else if($arg == 'change')//更改名单状态 { $this->_change(); } else if($arg == 'mdedit')//修改 { $this->_mdedit($arg_array); } else if($arg == 'black')//黑名单 { $this->_black(); } else if($arg == 'excela') { $this->_excela(); } else if($arg == 'excel')//下载excel { $this->_excel(); } else if($arg == 'indexexcel')//下载excel { $this->_indexexcel(); } else if($arg == 'down')//黑名单 { $this->_down(); } else if($arg == 'bankdown')//下载客户 { $this->_bankdown(); } else if($arg == 'newold')//新老客户比 { $this->_newold(); } else if($arg == 'dgso') { $this->_dgso(); } else if($arg == 'cx') { $this->_cx(); } else { $this->_index(); } } //管理 public function _index_xxxxxx()//通过索引订单查询购买次数,太慢,暂时抛弃 { $user = $this->user->get_api($_SESSION['api']); if($user) { $fgshop = "";$sid = ""; $user = explode('|',trim($user['shop'],'|')); foreach ($user as $value) { $fgshop .= " shop = ".$value." or"; $sid .= " id = ".$value." or"; } } $post = $this->input->post(NULL, TRUE); if(isset($post['page'])) { $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $shop = $this->input->post('shop',true); $numphone = $this->input->post('numphone',true); $name = $this->input->post('name',true); $email = $this->input->post('email',true); $address = $this->input->post('address',true); $level = $this->input->post('level',true); $num = $this->input->post('num',true); $timetk = $this->input->post('timetk',true); $timetj = $this->input->post('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = "1=1 and type = 1 and (".rtrim($fgshop,'or').")"; if($shop) { $where .= " and shop = '$shop'"; } if($numphone) { $where .= " and numphone = '$numphone'"; } if($name) { $where .= " and name like '%$name%'"; } if($email) { $where .= " and email like '%$email%'"; } if($level) { $where .= " and level = '$level'"; } if($address) { $where .= " and address like '%$address%'"; } if($timetk && $timetj) { //$where .= " and ((time > '$timetk' and time < '$timetj') or time = 0)"; $where .= " and ((time > '$timetk' and time < '$timetj') or time = '0')"; } //数据排序 $order_str = "id desc"; $numdata = array(); if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } //取得信息列表 if($num > 0) { $info_list = $this->customerxw->find_all($where,'id,shop,source,name,email,country,level,money,num,time,count,type',$order_str); } else { $info_list = $this->customerxw->find_all($where,'id,shop,source,name,email,country,level,money,num,time,count,type',$order_str,$start,$perpage); } foreach ($info_list as $key=>$value) { $shop = $this->shop->read($value['shop']); $info_list[$key]['shop'] = $shop['shopname']; $source = $this->typeclass->read($value['source']); $info_list[$key]['source'] = $source['title']; if($value['email'] != '0' && $value['email'] != '' && $value['email'] != '无') { $gnum = $this->fullorderxw->find_count("email = '".$value['email']."' and shop = '".$value['shop']."' and mergeid = 0 and buytime > '$timetk' and buytime < '$timetj'"); } else { $gnum = 0; } $info_list[$key]['num'] = $gnum; if($value['country'] != 0) { $country = $this->country->read($value['country']); $info_list[$key]['country'] = $country['name']; } else { $info_list[$key]['country'] = "未知"; } if($value['level'] == 1) { $info_list[$key]['level'] = "网红"; } else if($value['level'] == 2) { $info_list[$key]['level'] = "批发"; } else if($value['level'] == 3) { $info_list[$key]['level'] = "店铺转线下"; } else if($value['level'] == 4) { $info_list[$key]['level'] = "线下其他"; } else if($value['level'] == 5) { $info_list[$key]['level'] = "店内客户"; } if($value['time'] != 0) { $info_list[$key]['time'] = date('Y-m-d',$value['time']); } else { $info_list[$key]['time'] = "无"; } $info_list[$key]['type'] = "下单 移入黑名单"; if($num >= '10' && $gnum >= '10') { $numdata[] = $info_list[$key]; } else if ($num > '0' && $num < '10' && $gnum == $num) { $numdata[] = $info_list[$key]; } } if($num > 0) { $info_list = array_slice($numdata,$start,$perpage);; $total = count($numdata); } else { $total = $this->customerxw->find_count($where); } $pagenum = ceil($total/$perpage); $over = $total-($start+$perpage); $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list)); echo json_encode($rows);exit; } $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or')); $this->data['wlshop'] = $wlshop; $this->_Template('customerxw',$this->data); } public function _index()//通过计数,2020/02/21已校准 { $user = $this->user->get_api($_SESSION['api']); if($user) { $fgshop = "";$sid = ""; $users = explode('|',trim($user['shop'],'|')); foreach ($users as $value) { $fgshop .= " shop = ".$value." or"; $sid .= " id = ".$value." or"; } if($user['vip'] == 1) { $vip = 1; } else { $vip = 0; } } else { $vip = 0; } $post = $this->input->post(NULL, TRUE); if(isset($post['page'])) { $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $shop = $this->input->post('shop',true); $numphone = $this->input->post('numphone',true); $name = $this->input->post('name',true); $email = $this->input->post('email',true); $address = $this->input->post('address',true); $country = $this->input->post('country',true); $level = $this->input->post('level',true); $num = $this->input->post('num',true); $timetk = $this->input->post('timetk',true); $timetj = $this->input->post('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = "1=1 and type = 1 and (".rtrim($fgshop,'or').")"; if($shop) { $where .= " and shop = '$shop'"; } if($numphone != '') { if($numphone == '0') { $where .= " and phone = '$numphone'" ; } else { $where .= " and numphone = '$numphone' and phone != ''" ; } } if($name) { $where .= " and name like '%$name%'"; } if($country) { $where .= " and country = '$country'"; } if($email) { $where .= " and email like '%$email%'"; } if($level != '') { $where .= " and level = '$level'"; } if($address) { $where .= " and address like '%$address%'"; } if($num > 0 && $num < 10 && $num != '2a') { $where .= " and num = '$num'"; } else if($num > 9) { $where .= " and num > '9'"; } else if($num == '2a') { $where .= " and num > '1'"; } else if($num == '0') { $where .= " and num = '0'"; } else { $where .= " and num >= '0'"; } if($timetk && $timetj) { $where .= " and ((time > '$timetk' and time < '$timetj') or time = '0')"; } //数据排序 $order_str = "time desc"; $numdata = array(); if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } //取得信息列表 $info_list = $this->customerxw->find_all($where,'id,shop,source,name,email,phone,country,level,money,num,numphone,time,count,type',$order_str,$start,$perpage); foreach ($info_list as $key=>$value) { $shop = $this->shop->read($value['shop']); $info_list[$key]['shop'] = $shop['shopname']; $source = $this->typeclass->read($value['source']); $info_list[$key]['source'] = $source['title']; if($value['country'] != 0) { $country = $this->country->read($value['country']); $info_list[$key]['country'] = $country['name']; } else { $info_list[$key]['country'] = "未知"; } if($value['level'] == 1) { $info_list[$key]['level'] = "网红"; } else if($value['level'] == 2) { $info_list[$key]['level'] = "批发"; } else if($value['level'] == 3) { $info_list[$key]['level'] = "店铺转线下"; } else if($value['level'] == 4) { $info_list[$key]['level'] = "线下其他"; } else if($value['level'] == 5) { $info_list[$key]['level'] = "店内客户"; } else { $info_list[$key]['level'] = "未定义"; } if($value['time'] != 0) { $info_list[$key]['time'] = date('Y-m-d',$value['time']); } else { $info_list[$key]['time'] = "无"; } //$gmcs = $this->fullorderxw->find_count("email = '".$value['email']."' time > '$timetk' and time < '$timetj'"); //$info_list[$key]['num'] = $gmcs; $info_list[$key]['numphone'] = ($value['num'] > 0)?sprintf("%01.2f",$value['money']/$value['num']):0; $info_list[$key]['type'] = "
移入黑名单"; } $total = $this->customerxw->find_count($where); $pagenum = ceil($total/$perpage); $over = $total-($start+$perpage); $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list)); echo json_encode($rows);exit; } $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or')); $this->data['wlshop'] = $wlshop; $this->data['vip'] = $vip; $this->_Template('customerxw',$this->data); } public function _dgso() { $user = $this->user->get_api($_SESSION['api']); if($user) { $fgshop = "";$sid = ""; $users = explode('|',trim($user['shop'],'|')); foreach ($users as $value) { $fgshop .= " shop = ".$value." or"; $sid .= " id = ".$value." or"; } if($user['vip'] == 1) { $vip = 1; } else { $vip = 0; } } else { $vip = 0; } $post = $this->input->post(NULL, TRUE); if(isset($post['page'])) { $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $shop = $this->input->post('shop',true); $numphone = $this->input->post('numphone',true); $name = $this->input->post('name',true); $email = $this->input->post('email',true); $address = $this->input->post('address',true); $level = $this->input->post('level',true); $num = $this->input->post('num',true); $timetk = $this->input->post('timetk',true); $timetj = $this->input->post('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = "1=1 and (".rtrim($fgshop,'or').")"; if($numphone) { $where .= " and numphone = '$numphone'"; } if($email) { $where .= " and email like '%$email%'"; } if($address) { $where .= " and address like '%$address%'"; } if($numphone || $email || $address) { $d = $this->customerxw->find_all($where); $data = $this->customerxw->find_all("address like '%".$d[0]['address']."%' or email like '%".$d[0]['email']."%' or numphone like '%".$d[0]['numphone']."%'",'id,shop,source,name,email,country,level,money,num,time,type,numphone,address'); //$temp_key = array_column($data,'id'); //键值 //$Newdata = array_combine($temp_key,$data) ; $cx = array(); $info_list = $this->_dgcz($cx,$data); $info_list = array_values($info_list); $total = count($info_list); $pagenum = ceil($total/$perpage); $over = $total-$perpage; } else { //数据排序 $order_str = "id desc"; $numdata = array(); if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } //取得信息列表 $info_list = $this->customerxw->find_all($where,'id,shop,source,name,email,country,level,money,num,time,type',$order_str,$start,$perpage); $total = $this->customerxw->find_count($where); $pagenum = ceil($total/$perpage); $over = $total-($start+$perpage); } foreach ($info_list as $key=>$value) { $shop = $this->shop->read($value['shop']); $info_list[$key]['shop'] = $shop['shopname']; $source = $this->typeclass->read($value['source']); $info_list[$key]['source'] = $source['title']; if($value['country'] != 0) { $country = $this->country->read($value['country']); $info_list[$key]['country'] = $country['name']; } else { $info_list[$key]['country'] = "未知"; } if($value['level'] == 1) { $info_list[$key]['level'] = "网红"; } else if($value['level'] == 2) { $info_list[$key]['level'] = "批发"; } else if($value['level'] == 3) { $info_list[$key]['level'] = "店铺转线下"; } else if($value['level'] == 4) { $info_list[$key]['level'] = "线下其他"; } else if($value['level'] == 5) { $info_list[$key]['level'] = "店内客户"; } if($value['time'] != 0) { $info_list[$key]['time'] = date('Y-m-d',$value['time']); } else { $info_list[$key]['time'] = "无"; } if($value['type'] != 2) { $info_list[$key]['type'] = "下单 移入黑名单"; } else { $info_list[$key]['type'] = "黑名单客户"; } unset($info_list[$key]['numphone']); unset($info_list[$key]['address']); } $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list)); echo json_encode($rows);exit; } $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or')); $this->data['wlshop'] = $wlshop; $this->data['vip'] = $vip; $this->_Template('customerxw_dgso',$this->data); } public function _dgcz($child,$data) { foreach ($data as $key => $value) { if (!isset($child[$value['id']])) { $child[$value['id']] = $value; $rows = $this->customerxw->find_all("address like '%".$value['address']."%' or email like '%".$value['email']."%' or numphone like '%".$value['numphone']."%'",'id,shop,source,name,email,country,level,money,num,time,type,numphone,address'); $this->_dgcz($child,$rows); } } return $child; } //管理 public function _black() { /** $user = $this->user->get_api($_SESSION['api']); if($user) { $fgshop = "";$sid = ""; $user = explode('|',trim($user['shop'],'|')); foreach ($user as $value) { $fgshop .= " shop = ".$value." or"; $sid .= " id = ".$value." or"; } } **/ $post = $this->input->post(NULL, TRUE); if(isset($post['page'])) { $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $shop = $this->input->post('shop',true); $numphone = $this->input->post('numphone',true); $name = $this->input->post('name',true); $email = $this->input->post('email',true); $address = $this->input->post('address',true); $xtime = $this->input->post('xtime',true); //$where = "1=1 and type = 2 and (".rtrim($fgshop,'or').")"; $timetk = $this->input->post('timetk',true); $timetj = $this->input->post('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = "1=1 and type = 2"; if($shop) { $where .= " and shop = '$shop'"; } if($xtime) { $where .= " and typetime > '$timetk' and typetime < '$timetj'"; } if($numphone != '') { if($numphone == '0') { $where .= " and phone = '$numphone'" ; } else { $where .= " and numphone = '$numphone' and phone != ''" ; } } if($name) { $where .= " and name like '%$name%'"; } if($email) { $where .= " and email like '%$email%'"; } $hmdaddress1 = str_replace(array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),strtolower($address)); $hmdaddress2 = str_replace(array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),strtolower($address)); $hmdaddress3 = str_replace(array(' avenue',' ave',' av'),array(' ave',' avenue',' ave'),strtolower($address)); if($address) { $where .= " and (address like '%$address%' or address like '%$hmdaddress1%' or address like '%$hmdaddress2%' or address like '%$hmdaddress3%')"; } //数据排序 $order_str = "id desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } //取得信息列表 $info_list = $this->customerxw->find_all($where,'id,shop,source,name,email,address,phone,count,typetime,type',$order_str,$start,$perpage); foreach ($info_list as $key=>$value) { $shop = $this->shop->read($value['shop']); $info_list[$key]['shop'] = $shop['shopname']; $source = $this->typeclass->read($value['source']); $info_list[$key]['source'] = $source['title']; if($value['typetime'] > 0) { $info_list[$key]['typetime'] = date('Y-m-d',$value['typetime']); } else { $info_list[$key]['typetime'] = '无'; } $info_list[$key]['type'] = "移出"; } $total = $this->customerxw->find_count($where); $pagenum = ceil($total/$perpage); $over = $total-($start+$perpage); $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'a'=>$hmdaddress1); echo json_encode($rows);exit; } if(isset($post['s'])) { $id_arr = $this->input->post('s'); $id_arr = explode(',',$id_arr); if(!$id_arr) { echo json_encode(array('msg'=>'参数错误!','success'=>false));exit; } //循环删除记录 foreach ($id_arr as $v) { $this->customerxw->remove($v); } echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit; } //$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or')); $wlshop = $this->shop->find_all('1=1'); $this->data['wlshop'] = $wlshop; $this->_Template('customerxw_black',$this->data); } public function _cx() { $post = $this->input->post(NULL, TRUE); if(isset($post['page'])) { $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $shop = $this->input->post('shop',true); $numphone = $this->input->post('numphone',true); $name = $this->input->post('name',true); $email = $this->input->post('email',true); $address = $this->input->post('address',true); $xtime = $this->input->post('xtime',true); //$where = "1=1 and type = 2 and (".rtrim($fgshop,'or').")"; $timetk = $this->input->post('timetk',true); $timetj = $this->input->post('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = "1=1 and type = 2"; if($shop) { $where .= " and shop = '$shop'"; } if($xtime) { $where .= " and typetime > '$timetk' and typetime < '$timetj'"; } if($numphone) { $where .= " and numphone = '$numphone'"; } if($name) { $where .= " and name like '%$name%'"; } if($email) { $where .= " and email like '%$email%'"; } $hmdaddress1 = str_replace(array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),strtolower($address)); $hmdaddress2 = str_replace(array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),strtolower($address)); $hmdaddress3 = str_replace(array(' avenue',' ave',' av'),array(' ave',' avenue',' ave'),strtolower($address)); if($address) { $where .= " and (address like '%$address%' or address like '%$hmdaddress1%' or address like '%$hmdaddress2%' or address like '%$hmdaddress3%')"; } //数据排序 $order_str = "id desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } //取得信息列表 $info_list = $this->customerxw->find_all($where,'id,shop,source,name,email,address,phone,count,typetime',$order_str,$start,$perpage); foreach ($info_list as $key=>$value) { $shop = $this->shop->read($value['shop']); $info_list[$key]['shop'] = $shop['shopname']; $source = $this->typeclass->read($value['source']); $info_list[$key]['source'] = $source['title']; if($value['typetime'] > 0) { $info_list[$key]['typetime'] = date('Y-m-d',$value['typetime']); } else { $info_list[$key]['typetime'] = '无'; } } $total = $this->customerxw->find_count($where); $pagenum = ceil($total/$perpage); $over = $total-($start+$perpage); $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'a'=>$hmdaddress1); echo json_encode($rows);exit; } if(isset($post['s'])) { $id_arr = $this->input->post('s'); $id_arr = explode(',',$id_arr); if(!$id_arr) { echo json_encode(array('msg'=>'参数错误!','success'=>false));exit; } //循环删除记录 foreach ($id_arr as $v) { $this->customerxw->remove($v); } echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit; } $wlshop = $this->shop->find_all('1=1'); $this->data['wlshop'] = $wlshop; $this->_Template('customerxw_black_cx',$this->data); } //添加 public function _add() { $user = $this->user->get_api($_SESSION['api']); if($user) { $fgshop = "";$sid = ""; $user = explode('|',trim($user['shop'],'|')); foreach ($user as $value) { $fgshop .= " shop = ".$value." or"; $sid .= " id = ".$value." or"; } } $post = $this->input->post(NULL, TRUE); if(isset($post['shop'])) { $post['shop'] = $this->input->post('shop',true); $post['source'] = $this->input->post('source',true); $post['level'] = $this->input->post('level',true); $post['country'] = $this->input->post('country',true); $name = $this->input->post('name',true); $post['name'] = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$name); $post['phone'] = $this->input->post('phone',true); $email = $this->input->post('email',true); $post['email'] = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$email); $post['province'] = $this->input->post('province',true); $post['city'] = $this->input->post('city',true); //$post['street'] = $this->input->post('street',true); $address = $this->input->post('address',true); $post['address'] = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$address); //$post['address2'] = $this->input->post('address2',true); $post['count'] = $this->input->post('count',true); $str = $post['phone']; preg_match_all('/[0-9]/u',$str,$result); $numphone = join('',$result[0]); $post['numphone'] = $numphone; $post['zhcx'] = $post['shop'].'-'.$post['email']; $kh = $this->customerxw->get_email($post['email'],$post['shop']); if($kh) { echo json_encode(array('msg'=>'此客户已存在!','success'=>false));exit; } if($this->customerxw->insert($post)) { echo json_encode(array('msg'=>'添加成功','success'=>true));exit; } else { echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit; } } $country = $this->country->find_all('1=1','id,name','name asc'); $this->data['country'] = $country; $wlshop = $this->shop->find_all("type = 1514 and (".rtrim($sid,'or').")"); $this->data['wlshop'] = $wlshop; $this->_Template('customerxw_add',$this->data); } //修改 public function _edit($arg_array) { $user = $this->user->get_api($_SESSION['api']); if($user) { $fgshop = "";$sid = ""; $user = explode('|',trim($user['shop'],'|')); foreach ($user as $value) { $fgshop .= " shop = ".$value." or"; $sid .= " id = ".$value." or"; } } $post = $this->input->post(NULL, TRUE); if(isset($post['id'])) { $id = $this->input->post('id',true); $us = $this->customerxw->read($id); $post['shop'] = $this->input->post('shop',true); $post['source'] = $this->input->post('source',true); $post['level'] = $this->input->post('level',true); $post['country'] = $this->input->post('country',true); $name = $this->input->post('name',true); $post['name'] = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$name); $post['phone'] = $this->input->post('phone',true); $email = $this->input->post('email',true); $post['email'] = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$email); $post['province'] = $this->input->post('province',true); $post['city'] = $this->input->post('city',true); //$post['street'] = $this->input->post('street',true); $address = $this->input->post('address',true); $post['address'] = str_replace(array('/( | | |\s)/',"'"),array(' ',"’"),$address); //$post['address2'] = $this->input->post('address2',true); $post['type'] = $this->input->post('type',true); $post['count'] = $this->input->post('count',true); $str = $post['phone']; preg_match_all('/[0-9]/u',$str,$result); $numphone = join('',$result[0]); $post['numphone'] = $numphone; $post['zhcx'] = $post['shop'].'-'.$post['email']; if($this->customerxw->save($post,$id)) { echo json_encode(array('msg'=>'操作成功!','success'=>true));exit; } else { echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit; } } $arg_array = $arg_array[0]; $customerxw = $this->customerxw->read($arg_array); $this->data['customerxw'] = $customerxw; $country = $this->country->find_all('1=1','id,name','name asc'); $this->data['country'] = $country; $wlshop = $this->shop->find_all("type = 1514 and (".rtrim($sid,'or').")"); $this->data['wlshop'] = $wlshop; if($customerxw['email'] != '0' && $customerxw['email'] != '' && $customerxw['email'] != '无') { $fdata = $this->fullorderxw->find_all('email = "'.$customerxw['email'].'" and shop = "'.$customerxw['shop'].'" and mergeid = 0','orderinfo,state,product,name,email,dtime,shouldmoney','id desc'); foreach ($fdata as $k=>$v) { $d = $this->fullorderxw->get_orderinfo($v['orderinfo']); $fdata[$k]['orderinfo'] = "".$v['orderinfo'].""; $typeclass = $this->typeclass->read($v['state']); $fdata[$k]['state'] = $typeclass['spare']; $fdata[$k]['dtime'] = date('Y-m-d',$v['dtime']); } $this->data['data'] = $fdata; } $this->_Template('customerxw_edit',$this->data); } //删除 public function _del() { $post = $this->input->post(NULL, TRUE); if(isset($post['s'])) { $id_arr = $this->input->post('s'); $id_arr = explode(',',$id_arr); if(!$id_arr) { echo json_encode(array('msg'=>'参数错误!','success'=>false));exit; } //循环删除记录 $a=0; foreach ($id_arr as $v) { $customerxw = $this->customerxw->read($v); if($customerxw['email'] != '0' && $customerxw['email'] != '' && $customerxw['email'] != '无') { $fdata = $this->fullorderxw->find_count('email = "'.$customerxw['email'].'" and shop = "'.$customerxw['shop'].'" and mergeid = 0'); } if($fdata > 0) { $a++; continue; } else { $this->customerxw->remove($v); } } if($a > 0) { echo json_encode(array('del'=>$id_arr,'msg'=>'无订单客户删除成功,有订单的客户无法删除!','success'=>true)); } else { echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true)); } } } //操作 public function _change() { $post = $this->input->post(NULL, TRUE); if(isset($post['type'])) { $type = $this->input->post('type',true); $id = $this->input->post('id',true); $count = $this->input->post('count',true); if($this->customerxw->save(array('type'=>$type,'count'=>$count,'typetime'=>time()),$id)) { echo json_encode(array('msg'=>'操作成功!','success'=>true));exit; } else { echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit; } } } //修改客户分类 public function _mdedit($arg_array) { $user = $this->user->get_api($_SESSION['api']); if($user) { $uu = $user; $fgshop = "";$sid = ""; $u = $user; $user = explode('|',trim($user['shop'],'|')); foreach ($user as $value) { $fgshop .= " shop = ".$value." or"; $sid .= " id = ".$value." or"; } } $post = $this->input->post(NULL, TRUE); if(isset($post['shop'])) { $fpcount = $this->input->post('fpcount',true); if(!$fpcount) { echo json_encode(array('msg'=>'需要先清理浏览器缓存,刷新当前页面后再试!','success'=>false));exit; } $customerxwid = $this->input->post('customerxwid',true); $shop = $this->input->post('shop',true); $sp = $this->shop->read($shop); $num = $this->fullorderxw->find_count('shop = "'.$sp['id'].'" and gtime = "'.date('Ymd',time()).'"'); $post['source'] = 1;//订单类型:1.线下订单2.PC3.手机 $post['state'] = 207;//订单状态:207等待发货 $post['review'] = 2;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过 $post['print'] = 1;//打印状态:1.不可打印2.未打印3.已打印 $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库 $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许 $post['link'] = $sp['link']; $post['issku'] = $sp['sku']; if($post['print'] != 3) { $post['librarynot'] = "订单未打印,未审核或未通过";//不能出库原因 } $orderinfo = $this->input->post('orderinfo',true); $post['shop'] = $sp['id']; $post['user'] = $sp['shopuser']; $post['number'] = $sp['shortname'].'-'.substr(date('ymd',time()),1).'-'.(substr(strval($num+1+1000),1,3));//编号 if($orderinfo != "") { $ordefin = $this->fullorderxw->get_orderinfo($orderinfo); if($ordefin) { echo json_encode(array('msg'=>'订单号重复!','success'=>false));exit; } else { $post['orderinfo'] = $orderinfo; } } else { $post['orderinfo'] = $sp['id'].date('ymdHis',time()).rand(0,1);//订单号 } /** if($post['paypal'] != '') { $pp = $this->fullorderxw->get_paypal($post['paypal']); if($pp) { echo json_encode(array('msg'=>'此交易号的订单已存在!','success'=>false));exit; } } **/ $post['client'] = $this->input->post('client',true);//客户名称 $btime = $this->input->post('buytime',true);//付款时间 $post['buytime'] = strtotime($btime);//时间转UX $post['dtime'] = time();//订单时间 $post['gtime'] = date('Ymd',time());//格式化时间 //$post['pay'] = $this->input->post('pay',true);//支付方式 $post['capital'] = $this->input->post('capital',true);//资金状态 $post['type'] = $this->input->post('warehouse',true);//发货仓库 $post['currency'] = $this->input->post('currency',true);//币种 $currency = $this->typeclass->read($post['currency']); $post['currencytitle'] = $currency['title'];//币种名称 $post['freight'] = $this->input->post('freight',true);//运费 $post['expressmoney'] = $this->input->post('expressmoney',true);//物流金额 $post['shouldmoney'] = $this->input->post('shouldmoney',true);//应收金额 $post['skje'] = $post['shouldmoney'];//收款金额 $product = $this->input->post('product');//产品名称 $product = str_replace(array('%26','%2B'),array('&','+'),$product); $post['product'] = preg_replace('/( | | |\s)/',' ',$product); $orderremarks = $this->input->post('orderremarks');//订单备注 $orderremarks = str_replace(array('%26','%2B'),array('&','+'),$orderremarks); $post['orderremarks'] = preg_replace('/( | | |\s)/',' ',$orderremarks); $shipremarks = $this->input->post('shipremarks');//仓库品名 $shipremarks = str_replace(array('%26','%2B'),array('&','+'),$shipremarks);//仓库品名 $post['shipremarks'] = preg_replace('/( | | |\s)/',' ',$shipremarks); $post['email'] = $this->input->post('email',true);//邮箱 $name = $this->input->post('name',true);//名称 $post['name'] = preg_replace('/( | | |\s)/',' ',$name); $post['phone'] = $this->input->post('phone',true);//电话 $post['phone'] = preg_replace('/\D/s','',$post['phone']); $post['country'] = $this->input->post('country',true);//国家 $ct = $this->country->read($post['country']);//国家 $post['al'] = $ct['lb'];//国家二字码 $post['province'] = $this->input->post('province',true);//省、州 $post['province'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['province']); //替换开头空字符 $post['province'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['province']); //替换结尾空字符 $post['city'] = $this->input->post('city',true);//城市 $post['city'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['city']); //替换开头空字符 $post['city'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['city']); //替换结尾空字符 $post['zipcode'] = $this->input->post('zipcode',true);//邮编 $post['zipcode'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['zipcode']); //替换开头空字符 $post['zipcode'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['zipcode']); //替换结尾空字符 $post['address'] = $this->input->post('address',true);//地址 $post['printtype'] = $this->input->post('printtype',true);//打印类型 $fpdata = $this->input->post('fpdata');//购买产品内容 $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata); $post['fpdata'] = $fpdata; $post['sbpm'] = $this->input->post('sbpm',true);//申报品名 $post['zwpm'] = $this->input->post('zwpm',true);//中文品名 $post['ts'] = $this->input->post('ts',true);//条数 $post['dtsbjz'] = $this->input->post('dtsbjz',true);//单条申报价 $post['zsbjz'] = $this->input->post('zsbjz',true);//总申报价 $post['zzl'] = $this->input->post('zzl',true);//总重量 $post['zjs'] = $this->input->post('zjs',true);//总件数 $post['express'] = $this->input->post('express',true);//快递公司 $post['printtype'] = $this->input->post('printtype',true);//打印类型 $post['quantity'] = $this->input->post('quantity',true);//数量 //$post['paypal'] = $this->input->post('paypal',true);//支付号 //$post['guarantee'] = $this->input->post('guarantee',true);//卖家保障 $post['msg'] = $this->input->post('msg',true);//发送留言类型 $post['ioss'] = $this->input->post('ioss',true); $post['sbpm'] = $this->input->post('sbpm',true); //$pay = $this->pay->get_typeclass($post['pay']); $yga = $post['shouldmoney']; $post['budget'] = 0; /** if($pay) { $ygc = $pay['estimaterate'];//预估到账公式 $ifbudget = eval("return $yga*1.$ygc;"); $post['estimaterate'] = $pay['estimaterate']; if($ifbudget > 0) { $post['budget'] = eval("return $yga*1.$ygc;");//预估到帐金额 } } else { $ygb = $sp['estimaterate'];//店铺默认到账公式 $ifbudget = eval("return $yga*1.$ygb;"); $post['estimaterate'] = $sp['estimaterate']; if($ifbudget > 0) { $post['budget'] = eval("return $yga*1.$ygb;");//预估到帐金额 } } **/ $ygb = $sp['estimaterate'];//店铺默认到账公式 $ifbudget = eval("return $yga*1.$ygb;"); $post['estimaterate'] = $sp['estimaterate']; if($ifbudget > 0) { $post['budget'] = eval("return $yga*1.$ygb;");//预估到帐金额 } $baddress = $this->input->post('baddress',true); $saddress = $this->input->post('saddress',true); $baddress = array_reverse(explode(',',$baddress)); $saddress = array_reverse(explode(',',$saddress)); $bar = '';$sar = ''; $cr = $this->country->read($post['country']); $baddress[1] = $cr['lb']; $saddress[1] = $cr['lb']; $baddress = array_reverse($baddress); $saddress = array_reverse($saddress); for($i=0;$i店铺 | 名称 | 邮箱 | 电话 | 国家 | 类型 | 总额 | 成交次数 | 客单价 | 最后购买日期 | 备注 |