| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828 | 
							- <?php defined('BASEPATH') OR exit('No direct script access allowed');
 
- class User extends Start_Controller {
 
- 	public function __construct(){
 
- 		parent::__construct();
 
- 		$this->load->library('session');
 
- 		$this->load->_model('Model_user','user');
 
- 		$this->load->_model('Model_nav','nav');
 
- 		$this->load->_model('Model_power','power');
 
- 		$this->load->_model('Model_shop','shop');
 
- 		$this->load->_model('Model_purchase','purchase');
 
- 		$this->load->_model('Model_warehouse','warehouse');
 
- 		$this->load->_model('Model_staff','staff');
 
- 		$this->load->_model('Model_fullorder','fullorder');
 
- 		$this->load->_model('Model_fullordertt','fullordertt');
 
- 		$this->load->_model('Model_fullordersmt','fullordersmt');
 
- 		$this->load->_model('Model_customer','customer');
 
- 		$this->load->_model('Model_customersmt','customersmt');
 
- 		$this->load->_model('Model_typeclass','typeclass');
 
- 		$this->load->_model('Model_transfer','transfer');
 
- 		$this->load->_model('Model_typeclass','typeclass');
 
- 		$this->load->_model('Model_customertt','customertt');
 
- 		$this->load->_model('Model_allocation','allocation');
 
- 	}
 
- 	//定义方法的调用规则 获取URI第二段值
 
-     public function _remap($arg,$arg_array)
 
-     {
 
- 		if($arg == 'tc')//退出
 
-         {
 
-              $this->_tc();
 
-         }
 
- 		else if($arg == 'data')//操作页
 
-         {
 
-              $this->_data();
 
-         }
 
- 		else if($arg == 'del')//删除
 
-         {
 
-              $this->_del();
 
-         }
 
- 		else if($arg == 'default')//默认页
 
-         {
 
-              $this->_default();
 
-         }
 
- 		else if($arg == 'add')//添加
 
-         {
 
-              $this->_add();
 
-         }
 
- 		else if($arg == 'edit')//修改
 
-         {
 
-              $this->_edit($arg_array);
 
-         }
 
- 		else if($arg == 'rows')//数据
 
-         {
 
-              $this->_rows();
 
-         }
 
- 		else if($arg == 'statistics')//数据
 
-         {
 
-              $this->_statistics();
 
-         }
 
- 		else if($arg == 'apple')//数据
 
-         {
 
-              $this->_apple();
 
-         }
 
- 		else if($arg == 'zzt')//数据
 
-         {
 
-              $this->_zzt();
 
-         }
 
- 		else if($arg == 'tjadd')//数据
 
-         {
 
-              $this->_tjadd();
 
-         }
 
- 		else if($arg == 'shopfx')//店铺分析
 
-         {
 
-              $this->_shopfx();
 
-         }
 
- 		else if($arg == 'shopfxlist')//店铺分析
 
-         {
 
-              $this->_shopfxlist();
 
-         }
 
- 		else
 
- 		{
 
- 			 $this->_index();
 
- 		}
 
-     }
 
- 	//首页
 
- 	public function _index()
 
- 	{
 
- 		$user = $this->user->get_api($_SESSION['api']);
 
- 		$this->data['user'] = $user;//登录的用户信息
 
- 		$power = $this->power->read($user['power']);
 
- 		$power = $power['powerid'];
 
- 		//$power = explode('|',trim($power,'|'));字符串转数组
 
- 		$dataa = $this->nav->find_all('type=1','*','px asc');
 
- 		$datab = $this->nav->find_all('type=2','*','px asc');
 
- 		$datac = $this->nav->find_all('type=3','*','sort asc,px desc');
 
- 		$an = array();
 
- 		 foreach ($dataa as $key=>$value) 
 
- 		    {
 
- 			    foreach ($datab as $ke=>$va) 
 
- 		        {
 
- 			    	if($va['class'] == $value['id'])
 
- 			        {
 
- 				    	foreach ($datac as $k=>$v) 
 
- 		                {
 
- 					    	if($v['class'] == $va['id'])
 
- 			                {
 
- 								if(strstr($power,'|'.$v['id'].'|')==true)
 
- 			                    {
 
- 					    		     $va['cn'][]=$v;
 
- 								}
 
- 			                }
 
- 			            }
 
- 						if(strstr($power,'|'.$va['id'].'|')==true)
 
- 			            {
 
- 						     $value['bn'][]=$va;
 
- 						}
 
- 			        }
 
- 			     }//循环出二级导航航
 
- 				 if(strstr($power,'|'.$value['id'].'|')==true)
 
- 			     {
 
- 				      $an[] = $value;
 
- 				 }
 
-             }
 
- 		//print_r($an);
 
- 		$this->data['data'] = $an;
 
- 		$this->data['ip'] = $this->input->ip_address();
 
- 		$this->data['power'] = $user['power'];
 
- 		$this->data['link'] = $user['link'];
 
- 		if(stripos($_SERVER ['HTTP_HOST'],'a.') !== false)
 
- 		{
 
- 			$url = 'b';
 
- 		}
 
- 		else
 
- 		{
 
- 			$url = 'a';
 
- 		}
 
- 		$this->data['url'] = $url;
 
- 		$this->_Template('user',$this->data);
 
- 	}
 
- 	
 
- 	//管理
 
- 	public function _data()
 
- 	{
 
- 		$user = $this->user->get_api($_SESSION['api']);
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['page']))  
 
- 		{
 
- 		    $page = $this->input->post('page',true);
 
- 		    $perpage = $this->input->post('perpage',true);
 
-             $power = $this->input->post('power',true);
 
- 		    $name = $this->input->post('name',true);
 
- 			$userid = $this->input->post('userid',true);
 
-             $where = "own='".$user['own']."'";
 
-             if($power)
 
-             {
 
-                 $where  .= " and power = '$power'";
 
-             }
 
- 		    if($name)
 
-             {
 
-                 $where  .= " and name like '%$name%'";
 
-             }
 
- 			 if($userid)
 
-             {
 
-                 $where  .= " and userid like '%$userid%'";
 
-             }
 
-             //数据排序
 
-             $order_str = "id asc";
 
-             if(empty($page))
 
- 		    {
 
-                 $start = 0;
 
- 		    	$perpage = 1;
 
-             }
 
- 		    else
 
- 		    {
 
-                 $start = ($page - 1)*$perpage;
 
-             }
 
-             //取得信息列表
 
-             $info_list = $this->user->find_all($where,'id,name,userid,power,shoptext,purchasetext,warehousetext,stafftext,transfertext,type',$order_str,$start,$perpage);
 
-             //格式化数据
 
-             foreach ($info_list as $key=>$value) 
 
- 		    {
 
- 		    	if($value['type'] == 1)
 
- 				{
 
- 					$info_list[$key]['type'] = '正常';
 
- 				}
 
- 				else
 
- 				{
 
- 					$info_list[$key]['type'] = '停用';
 
- 				}
 
- 				$power = $this->power->read($value['power']);
 
- 				$info_list[$key]['power'] = $power['powername'];
 
-             }
 
- 		    $total = $this->user->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;
 
- 		}
 
- 		$power = $this->power->find_all();
 
- 		$this->data['power'] = $power;
 
- 		$this->_Template('user_data',$this->data);
 
- 	}
 
- 	//添加
 
- 	public function _add()
 
- 	{
 
- 		$user = $this->user->get_api($_SESSION['api']);
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['userid']))
 
- 		{
 
- 			$post['userid'] = $this->input->post('userid',true);
 
- 			$userpass = $this->input->post('userpass',true);
 
- 			$post['userpass'] = sha1($userpass);
 
- 			$post['shop'] = $this->input->post('shop',true);
 
- 			$post['shoptext'] = $this->input->post('shoptext',true);
 
- 			$post['excelshop'] = $this->input->post('excelshop',true);
 
- 			$post['excelshoptext'] = $this->input->post('excelshoptext',true);
 
-         	$post['purchase'] = $this->input->post('purchase',true);
 
- 			$post['purchasetext'] = $this->input->post('purchasetext',true);
 
-         	$post['warehouse'] = $this->input->post('warehouse',true);
 
- 			$post['warehousetext'] = $this->input->post('warehousetext',true);
 
-         	$post['customer'] = $this->input->post('customer',true);
 
-         	$post['staff'] = $this->input->post('staff',true);
 
- 			$post['stafftext'] = $this->input->post('stafftext',true);
 
-         	$post['power'] = $this->input->post('power',true);
 
- 			$post['name'] = $this->input->post('name',true);
 
- 			$post['phone'] = $this->input->post('phone',true);
 
- 			$post['type'] = $this->input->post('type',true);
 
- 			$post['html'] = $this->input->post('html',true);
 
- 			$post['own'] = $user['own'];
 
- 			$post['api'] = sha1(rand(1000000,9999999));
 
- 			if($this->user->insert($post))
 
-         	{
 
-          		echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
 
-        	 	}
 
-        		else
 
-         	{
 
-            		echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
 
-         	}
 
- 		}
 
- 		$power = $this->power->find_all();
 
- 		$this->data['power'] = $power;
 
- 		$this->_Template('user_add',$this->data);
 
- 	}
 
- 	//修改
 
- 	public function _edit($arg_array)
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['id']))
 
- 		{
 
- 			$id = $this->input->post('id',true);
 
- 			$post['userid'] = $this->input->post('edituserid',true);
 
- 			$userpass = $this->input->post('edituserpass',true);
 
- 			$post['shop'] = $this->input->post('shop',true);
 
- 			$post['shoptext'] = $this->input->post('shoptext',true);
 
- 			$post['excelshop'] = $this->input->post('excelshop',true);
 
- 			$post['excelshoptext'] = $this->input->post('excelshoptext',true);
 
-         	$post['purchase'] = $this->input->post('purchase',true);
 
- 			$post['purchasetext'] = $this->input->post('purchasetext',true);
 
-         	$post['warehouse'] = $this->input->post('warehouse',true);
 
- 			$post['warehousetext'] = $this->input->post('warehousetext',true);
 
-         	$post['customer'] = $this->input->post('customer',true);
 
-         	$post['staff'] = $this->input->post('staff',true);
 
- 			$post['stafftext'] = $this->input->post('stafftext',true);
 
-         	$post['power'] = $this->input->post('power',true);
 
- 			$post['name'] = $this->input->post('name',true);
 
- 			$post['phone'] = $this->input->post('phone',true);
 
- 			$post['type'] = $this->input->post('type',true);
 
- 			$post['html'] = $this->input->post('html',true);
 
- 			$ud = $this->user->read($id);
 
- 			if($userpass != NULL)
 
- 			{
 
- 				$post['userpass'] = sha1($userpass);
 
- 				$post['api'] = sha1(rand(1000000,9999999));
 
- 			}
 
- 			else
 
- 			{
 
- 				$post['userpass'] = $ud['userpass'];
 
- 			}
 
- 			if($this->user->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];
 
- 		$user = $this->user->read($arg_array);
 
- 		$this->data['user'] = $user;
 
- 		$power = $this->power->find_all();
 
- 		$this->data['power'] = $power;
 
- 		$this->_Template('user_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;
 
-             }
 
-             //循环删除记录
 
-             foreach ($id_arr as $v) 
 
- 		    {
 
-                 $this->user->remove($v);
 
-             }
 
-             echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
 
- 		}
 
-     }
 
- 	//默认页
 
- 	public function _default()
 
- 	{
 
- 		/**
 
- 		$order = $this->order->get_w();
 
- 		$order = count($order);//查询订单未处理数量
 
- 		$message = $this->message->get_w();
 
- 		$message = count($message);//查询留言未处理数量
 
- 		$this->_Template('default',$this->data);
 
- 		**/
 
- 		$dt = 0;
 
- 		if(isset($_SESSION['api']))
 
- 		{
 
- 			$user = $this->user->get_api($_SESSION['api']);
 
- 			$usp = $user;
 
- 		    $fgshop = "";$sid = "";
 
- 		    $user = explode('|',trim($user['shop'],'|'));
 
- 			foreach ($user as $value) 
 
- 		    {
 
- 				if($value != '18' && $value != '19' && $value != '12' && $value != '13' && $value != '9' && $value != '15' && $value != '27')
 
- 				{
 
- 				    $fgshop .= " shop = ".$value." or";
 
- 				}
 
- 				$sid .= " id = ".$value." or";
 
- 			}
 
- 		}
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['timek']))  
 
- 		{
 
- 			//$start = '2018-10-15';
 
- 			//$end = '2018-11-26';
 
- 			//$tim = strtotime($start);
 
- 			//$day = $time/(3600*24);
 
- 			$timek = $this->input->post('timek',true);
 
- 			$timej = $this->input->post('timej',true);
 
- 			$k = strtotime($timek)-24*3600;//少一天为增加选择开始天时间
 
- 			$j = strtotime($timej);
 
- 			$n = ($j-$k)/(24*3600);
 
- 			if($n < 1)
 
- 			{
 
- 				$n = 1;
 
- 			}
 
- 		    $time=array();$stime=array();$num = array();$ymoney = array();$money = array();
 
- 		    for($i=1;$i<$n;$i++)
 
- 		    {
 
- 				//近7天时间
 
- 				$t = $j-($n*24*60*60)+($i*24*60*60);
 
- 			    $time[] = date('Y-m-d',$t);
 
- 				$ct = strtotime(date('Ymd',$t));
 
- 				$ctj = strtotime(date('Ymd',$t+24*3600));
 
- 				$dlz = $this->fullorder->find_all("dtime >= ".$ct." and dtime <= ".$ctj." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'budget,shouldmoney');
 
- 				$tt = $this->fullordertt->find_all("dtime >= ".$ct." and dtime <= ".$ctj." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'budget,shouldmoney');
 
- 				$dsmt = array();
 
- 				$dsmt = $this->fullordersmt->find_all("dtime >= ".$ct." and dtime <= ".$ctj." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'budget,shouldmoney');
 
- 				$d = array_merge($dlz,$dsmt,$tt);
 
- 				$num[] = count($d);
 
- 				$ymoney[] = sprintf("%01.2f",array_sum(array_column($d,'budget')));
 
- 				$money[] = sprintf("%01.2f",array_sum(array_column($d,'shouldmoney')));
 
- 		    }
 
- 			$snuz = $this->fullorder->find_count('dtime >='.($k+24*3600).' and dtime <='.$j.' and ('.rtrim($fgshop,'or').')');//待处理
 
- 			$snuz += $this->fullordersmt->find_count('dtime >='.($k+24*3600).' and dtime <='.$j.' and ('.rtrim($fgshop,'or').')');//待处理
 
- 			$snuz += $this->fullordertt->find_count('dtime >='.($k+24*3600).' and dtime <='.$j.' and ('.rtrim($fgshop,'or').')');//待处理
 
- 			$lnuz = $this->fullorder->find_count('dtime >='.($k+24*3600).' and dtime <='.$j.' and ('.rtrim($fgshop,'or').')');//待出库
 
- 			$lnuz += $this->fullordersmt->find_count('dtime >='.($k+24*3600).' and dtime <='.$j.' and ('.rtrim($fgshop,'or').')');//待出库
 
- 			$lnuz += $this->fullordertt->find_count('dtime >='.($k+24*3600).' and dtime <='.$j.' and ('.rtrim($fgshop,'or').')');//待出库
 
- 			$snu = $this->fullorder->find_count('reviewtime = 0 and dtime >='.($k+24*3600).' and dtime <='.$j.' and ('.rtrim($fgshop,'or').')');//待处理
 
- 			$snu += $this->fullordersmt->find_count('reviewtime = 0 and dtime >='.($k+24*3600).' and dtime <='.$j.' and ('.rtrim($fgshop,'or').')');//待处理
 
- 			$snu += $this->fullordertt->find_count('reviewtime = 0 and dtime >='.($k+24*3600).' and dtime <='.$j.' and ('.rtrim($fgshop,'or').')');//待处理
 
- 		    $lnu = $this->fullorder->find_count('printtime != 0 and librarytime = 0 and libraryconfirm = 2 and dtime >='.($k+24*3600).' and dtime <='.$j.' and ('.rtrim($fgshop,'or').')');//待出库
 
- 			$lnu += $this->fullordersmt->find_count('printtime != 0 and librarytime = 0 and libraryconfirm = 2 and dtime >='.($k+24*3600).' and dtime <='.$j.' and ('.rtrim($fgshop,'or').')');//待出库
 
- 			$lnu += $this->fullordertt->find_count('printtime != 0 and librarytime = 0 and libraryconfirm = 2 and dtime >='.($k+24*3600).' and dtime <='.$j.' and ('.rtrim($fgshop,'or').')');//待出库
 
- 			echo @json_encode(array('time'=>$time,'num'=>$num,'ymoney'=>$ymoney,'money'=>$money,'snu'=>$snu,'lnu'=>$lnu,'snuz'=>sprintf("%.0f",$snu/$snuz*100).'%','lnuz'=>sprintf("%.0f",$lnu/$lnuz*100).'%','success'=>true));exit;
 
- 		}
 
- 		$this->_Template('user_default',$this->data);
 
- 	}
 
- 	
 
- 	
 
- 	public function _zzt()
 
- 	{
 
- 		exit;
 
- 		if(isset($_SESSION['api']))
 
- 		{
 
- 			$user = $this->user->get_api($_SESSION['api']);
 
- 			$usp = $user;
 
- 		    $fgshop = "";$sid = "";
 
- 		    $user = explode('|',trim($user['shop'],'|'));
 
- 			foreach ($user as $value) 
 
- 		    {
 
- 				$fgshop .= " shop = ".$value." or";
 
- 				$sid .= " id = ".$value." or";
 
- 			}
 
- 		}
 
- 		$data = array();$sntime= array();$sndata1 = array();$sndata2 = array();$sndata3 = array();
 
- 		$sj = array('01','02','03','04','05','06','07','08','09','10','11','12');
 
- 		for($i=0;$i<3;$i++)
 
- 		{
 
- 			foreach ($sj as $v) 
 
- 		    {
 
- 				$sntime[] = date("Y")-2+$i.'-'.$v;
 
- 			}
 
- 		}
 
- 		$pdtime = date('Y-m-d-H',time());
 
- 		if(is_file("./data/tj/".$pdtime.".txt"))
 
- 		{
 
- 			$myfile = fopen("./data/tj/".$pdtime.".txt", "r") or die("Unable to open file!");
 
-             $bc = fread($myfile,filesize("./data/tj/".$pdtime.".txt"));
 
-             fclose($myfile);
 
- 			$bc = json_decode($bc,true);
 
- 			$data = $bc['zzt'][0];
 
- 			$sndata = $bc['zzt'][1];
 
- 		}
 
- 		else
 
- 		{
 
- 			$i = 0;
 
- 			foreach ($sj as $k=>$v) 
 
- 		    {
 
- 				$i++;
 
- 				$dlz1 = $this->fullorder->find_all("gtime > '".date("Y").$v."00' and gtime < '".date("Y").$v."32'",'shouldmoney');
 
- 				$smt1 = $this->fullordersmt->find_all("gtime > '".date("Y").$v."00' and gtime < '".date("Y").$v."32'",'shouldmoney');
 
- 				$m1 = sprintf("%01.2f",array_sum(array_column($dlz1,'shouldmoney'))+array_sum(array_column($smt1,'shouldmoney')));
 
- 				
 
- 				$dlz2 = $this->fullorder->find_all("gtime > '".(date("Y")-1).$v."00' and gtime < '".(date("Y")-1).$v."32'",'shouldmoney');
 
- 				$smt2 = $this->fullordersmt->find_all("gtime > '".(date("Y")-1).$v."00' and gtime < '".(date("Y")-1).$v."32'",'shouldmoney');
 
- 				$m2 = sprintf("%01.2f",array_sum(array_column($dlz2,'shouldmoney'))+array_sum(array_column($smt2,'shouldmoney')));
 
- 				
 
- 				$dlz3 = $this->fullorder->find_all("gtime > '".(date("Y")-2).$v."00' and gtime < '".(date("Y")-2).$v."32'",'shouldmoney');
 
- 				$smt3 = $this->fullordersmt->find_all("gtime > '".(date("Y")-2).$v."00' and gtime < '".(date("Y")-2).$v."32'",'shouldmoney');
 
- 				$m3 = sprintf("%01.2f",array_sum(array_column($dlz3,'shouldmoney'))+array_sum(array_column($smt3,'shouldmoney')));
 
- 				
 
- 				$sndata1[$i] = $m3;
 
- 				$sndata2[12+$i] = $m2;
 
- 				$sndata3[24+$i] = $m1;
 
- 				$data[] = array($v,$m1,$m2,$m3);
 
- 			}
 
- 		}
 
- 		$time = array(date("Y"),(date("Y")-1),(date("Y")-2));
 
- 		echo json_encode(array('data'=>$data,'time'=>$time,'sndata'=>$sndata,'sntime'=>$sntime,'success'=>true));exit;
 
- 	}
 
- 	
 
- 	
 
- 	//默认页
 
- 	public function _statistics()
 
- 	{
 
- 		/**
 
- 		$order = $this->order->get_w();
 
- 		$order = count($order);//查询订单未处理数量
 
- 		$message = $this->message->get_w();
 
- 		$message = count($message);//查询留言未处理数量
 
- 		$this->_Template('default',$this->data);
 
- 		**/
 
- 		//date_default_timezone_set("Etc/GMT+8");
 
- 		$dt = 0;
 
- 		if(isset($_SESSION['api']))
 
- 		{
 
- 			$user = $this->user->get_api($_SESSION['api']);
 
- 			$usp = $user;
 
- 		    $fgshop = "";$sid = "";
 
- 		    $user = explode('|',trim($user['shop'],'|'));
 
- 			foreach ($user as $value) 
 
- 		    {
 
- 				if($value != '18' && $value != '19' && $value != '12' && $value != '13' && $value != '9' && $value != '15' && $value != '27' && $value != '28' && $value != '29' && $value != '30' && $value != '21' && $value != '34')
 
- 				{
 
- 				    $fgshop .= " shop = ".$value." or";
 
- 				}
 
- 				$sid .= " id = ".$value." or";
 
- 			}
 
- 		}
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		$source = $this->input->post('source',true);
 
- 		$where = "";
 
- 		if($source)
 
- 		{
 
- 			if($source == '2d')
 
- 			{
 
- 				$where = " and source >= '2'";
 
- 			}
 
- 			else
 
- 			{
 
- 			    $where = " and source = '$source'";
 
- 			}
 
- 		}
 
- 		$tm = strtotime(date("Ymd"),time());
 
- 		$usat = $tm;
 
- 		if(isset($post['zhcx']))  
 
- 		{
 
- 			$zdt = $this->input->post('time',true);
 
- 			$k = $zdt;
 
- 			$tab = $this->input->post('tab',true);
 
- 			$pdtime = date('Y-m-d-H',time());
 
- 		    if(is_file("./data/tj/".$pdtime.".txt") && $tab == 1 && $zdt > 172800)
 
- 		    {
 
- 			    $myfile = fopen("./data/tj/".$pdtime.".txt", "r") or die("Unable to open file!");
 
-                 $bc = fread($myfile,filesize("./data/tj/".$pdtime.".txt"));
 
-                 fclose($myfile);
 
- 			    $bc = json_decode($bc,true);
 
- 			    echo json_encode($bc['zhcx'][$source][$zdt]);exit;
 
- 		    }
 
- 		    else
 
- 		    {
 
- 			$customer = $this->customer->find_all("shop !=''",'num,zhcx');
 
- 			$customerkey = array_column($customer,'zhcx'); 
 
-             $customer= array_combine($customerkey,$customer);
 
- 			$customersmt = $this->customersmt->find_all("shop !=''",'num,zhcx');
 
- 			$customersmtkey = array_column($customersmt,'zhcx'); 
 
-             $customersmt= array_combine($customersmtkey,$customersmt);
 
- 			//$start = '2018-10-15';
 
- 			//$end = '2018-11-26';
 
- 			//$tim = strtotime($start);
 
- 			//$day = $time/(3600*24);
 
- 			if($tab == '1')
 
- 			{
 
- 				if($zdt >= 691200)
 
- 				{
 
- 					$k = $usat-$k-$k;
 
- 			        $j = $usat;
 
- 				    $n = ($j-$k)/(24*3600);
 
- 				}
 
- 				else
 
- 				{
 
- 					$n = 2;
 
- 			        $usat = strtotime(date("Ymd"),time())-$k+2*24*3600;
 
- 				}
 
- 			}
 
- 			else
 
- 			{
 
- 			    $timedata = explode('|',$zdt);
 
- 				$ktime = strtotime($timedata[0]);
 
- 			    $jtime = strtotime($timedata[1]);
 
- 				$ktime = $ktime-($jtime-$ktime);
 
- 				$k = $ktime;
 
- 			    $j = $jtime;
 
- 				$n = ($j-$k)/(24*3600);
 
- 				$usat = $jtime;
 
- 			}
 
- 		    $time=array();$timeold=array();$stime=array();$dlznum = array();$smtnum = array();$ymoney = array();$money = array();
 
- 			$dlzmoneyb=array();$smtmoneyb=array();$ttmoneyb=array();$zkh = array();
 
- 			$dlzsl=0;$dlzje=0;$dlzssje=0;$smtsl=0;$smtje=0;$smtssje=0;$ttsl=0;$ttje=0;$ttssje=0;$shopdata = array();
 
- 			$ys = $this->shop->find_all("type != '0' and id != '18' and id != '19' and id != '12' and id != '13' and id != '9' and id != '15' and id != '27' and id != '28' and id != '29' and id != '30' and id != '21' and id != '34'");
 
- 			foreach ($ys as $v) 
 
- 		    {
 
- 				$shopdata[$v['id']] = array('id'=>$v['id'],'b'=>$v['type'],'fdl'=>0,'chl'=>0,'num'=>0,'fgl'=>0);
 
- 				$zkh[$v['id']] = array();
 
- 			}
 
- 		    for($i=1;$i<$n;$i++)
 
- 		    {
 
- 				if($n > 13 && $i > $n/2 || $n < 14)
 
- 				{
 
- 				$t = $usat-($n*24*60*60)+($i*24*60*60);
 
- 			    $time[] = date('m-d',$t);
 
- 				$ct = strtotime(date('Ymd',$t));
 
- 				$ctj = strtotime(date('Ymd',$t+24*3600));
 
- 				$dlz = $this->fullorder->find_all("dtime >= ".$ct." and dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'shop,email');
 
- 				$smt = $this->fullordersmt->find_all("dtime >= ".$ct." and dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'shop,userid');
 
- 				$tt = $this->fullordertt->find_all("state != 217 and dtime >= ".$ct." and dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'shop,email');
 
- 				//数量及金额结束
 
- 				$sd = array_merge($dlz,$smt,$tt);
 
- 				$fgldata = array();
 
- 				foreach ($sd as $v) 
 
- 		        {
 
- 					if(isset($v['email']))
 
- 					{
 
- 					    if(!isset($fgldata[$v['shop'].'-'.$v['email']]))
 
- 					    {
 
- 							$fgldata[$v['shop'].'-'.$v['email']] = 0;
 
- 					    }
 
- 						else
 
- 						{
 
- 							$fgldata[$v['shop'].'-'.$v['email']] += 1;
 
- 						}
 
- 						$zkh[$v['shop']][$v['email']] = array();
 
- 					}
 
- 					else
 
- 					{
 
- 						if(!isset($fgldata[$v['shop'].'-'.$v['userid']]))
 
- 					    {
 
- 							$fgldata[$v['shop'].'-'.$v['userid']] = 0;
 
- 					    }
 
- 						else
 
- 						{
 
- 							$fgldata[$v['shop'].'-'.$v['userid']] += 1;
 
- 						}
 
- 						$zkh[$v['shop']][$v['userid']] = array();
 
- 					}
 
- 				}
 
- 				foreach ($sd as $v) 
 
- 		        {
 
- 					$chl = 0;
 
- 					if(isset($shopdata[$v['shop']]))
 
- 					{
 
- 						if(isset($v['email']))
 
- 						{
 
- 							if(isset($customer[$v['shop'].'-'.$v['email']]['num']))
 
- 							{
 
- 							    $fdl = $customer[$v['shop'].'-'.$v['email']]['num']>1?1:0;
 
- 							}
 
- 							else
 
- 							{
 
- 								$fdl = 0;
 
- 							}
 
- 							foreach ($ys as $vv) 
 
- 		                    {
 
- 				                if($vv['id'] != $v['shop'] && isset($customer[$vv['id'].'-'.$v['email']]))
 
- 								{
 
- 									$chl = 1;
 
- 								}
 
- 			                }
 
- 							if(isset($fgldata[$v['shop'].'-'.$v['email']]))
 
- 							{
 
- 							    $fgl = $fgldata[$v['shop'].'-'.$v['email']]>0?1:0;
 
- 							}
 
- 							else
 
- 							{
 
- 								$fgl = 0;
 
- 							}
 
- 						}
 
- 						else
 
- 						{
 
- 							if(isset($customersmt[$v['shop'].'-'.$v['userid']]['num']))
 
- 							{
 
- 							    $fdl = $customersmt[$v['shop'].'-'.$v['userid']]['num']>1?1:0;
 
- 							}
 
- 							else
 
- 							{
 
- 								$fdl = 0;
 
- 							}
 
- 							foreach ($ys as $vv) 
 
- 		                    {
 
- 				                if($vv['id'] != $v['shop'] && isset($customersmt[$vv['id'].'-'.$v['userid']]))
 
- 								{
 
- 									$chl = 1;
 
- 								}
 
- 			                }
 
- 							if(isset($fgldata[$v['shop'].'-'.$v['userid']]))
 
- 							{
 
- 							    $fgl = $fgldata[$v['shop'].'-'.$v['userid']]>0?1:0;
 
- 							}
 
- 							else
 
- 							{
 
- 								$fgl = 0;
 
- 							}
 
- 						}
 
- 					    $shopdata[$v['shop']]['fdl'] = $shopdata[$v['shop']]['fdl']+$fdl;
 
- 						$shopdata[$v['shop']]['chl'] = $shopdata[$v['shop']]['chl']+$chl;
 
- 						$shopdata[$v['shop']]['fgl'] = $shopdata[$v['shop']]['fgl']+$fgl;
 
- 						$shopdata[$v['shop']]['num'] += 1;
 
- 					}
 
-                 }
 
- 				}
 
- 		    }
 
- 			foreach ($shopdata as $k=>$v) 
 
- 		    {
 
- 				$shopdata[$k]['fdl'] = $v['num']=='0'?0:sprintf("%01.2f",($v['fdl']/$v['num']*100)).'%';
 
- 				$shopdata[$k]['chl'] = $v['num']=='0'?0:sprintf("%01.2f",($v['chl']/$v['num']*100)).'%';
 
- 				$shopdata[$k]['fgl'] = count($zkh[$v['id']])=='0'?0:sprintf("%01.2f",($v['fgl']/count($zkh[$v['id']])*100)).'%';
 
- 			}
 
- 			$shopdata = array_values($shopdata);
 
- 			echo @json_encode(array('shopdata'=>$shopdata,'success'=>true));exit;
 
- 			}
 
- 		}
 
- 		if(isset($post['time']))  
 
- 		{
 
- 			$zdt = $this->input->post('time',true);
 
- 			$k = $zdt;
 
- 			$tab = $this->input->post('tab',true);
 
- 			$pdtime = date('Y-m-d-H',time());
 
- 		    if(is_file("./data/tj/".$pdtime.".txt") && $tab == 1 && $zdt > 172800)//前端改店内需要修改zdt   172800
 
- 		    {
 
- 			    $myfile = fopen("./data/tj/".$pdtime.".txt", "r") or die("Unable to open file!");
 
-                 $bc = fread($myfile,filesize("./data/tj/".$pdtime.".txt"));
 
-                 fclose($myfile);
 
- 			    $bc = json_decode($bc,true);
 
- 			    echo json_encode($bc['tj'][$source][$zdt]);exit;
 
- 		    }
 
- 		    else
 
- 		    {
 
- 			//$start = '2018-10-15';
 
- 			//$end = '2018-11-26';
 
- 			//$tim = strtotime($start);
 
- 			//$day = $time/(3600*24);
 
- 			if($tab == '1')
 
- 			{
 
- 				if($zdt >= 691200)
 
- 				{
 
- 					$k = $usat-$k-$k;
 
- 			        $j = $usat;
 
- 				    $n = ($j-$k)/(24*3600);
 
- 				}
 
- 				else
 
- 				{
 
- 					$n = 2;
 
- 			        $usat = strtotime(date("Ymd"),time())-$k+2*24*3600;
 
- 				}
 
- 			}
 
- 			else
 
- 			{
 
- 			    $timedata = explode('|',$zdt);
 
- 				$ktime = strtotime($timedata[0]);
 
- 			    $jtime = strtotime($timedata[1]);
 
- 				$ktime = $ktime-($jtime-$ktime);
 
- 				$k = $ktime;
 
- 			    $j = $jtime;
 
- 				$n = ($j-$k)/(24*3600);
 
- 				$usat = $jtime;
 
- 				$tm = $jtime;
 
- 				$zdt = $jtime-$ktime;
 
- 			}
 
- 		    $time=array();$timeold=array();$stime=array();$dlznum = array();$smtnum = array();$ymoney = array();$money = array();
 
- 			$dlzmoneyb=array();$smtmoneyb=array();$ttmoneyb=array();$zkh = array();
 
- 			$dlzsl=0;$dlzje=0;$dlzssje=0;$smtsl=0;$smtje=0;$smtssje=0;$ttsl=0;$ttje=0;$ttssje=0;$shopdata = array();
 
- 			$ys = $this->shop->find_all("type != '0' and id != '16' and id != '17' and id != '18' and id != '19' and id != '20' and id != '12' and id != '13' and id != '8' and id != '10' and id != '11' and id != '13' and id != '22' and id != '23' and id != '24' and id != '25' and id != '26' and id != '9' and id != '15' and id != '27' and id != '28' and id != '29' and id != '30' and id != '21' and id != '34'");
 
- 			foreach ($ys as $v) 
 
- 		    {
 
- 				$shopdata[$v['id']] = array('num'=>0,'money'=>0,'tmoney'=>0,'fdl'=>0,'chl'=>0);
 
- 			}
 
- 		    for($i=1;$i<$n;$i++)
 
- 		    {
 
- 				//近7天时间
 
- 				//$t = ($usat-16*3600)-($n*24*60*60)+($i*24*60*60);
 
- 				if($n > 13 && $i > $n/2 || $n < 14)
 
- 				{
 
- 				$t = $usat-($n*24*60*60)+($i*24*60*60);
 
- 			    $time[] = date('m-d',$t);
 
- 				$ct = strtotime(date('Ymd',$t));
 
- 				$ctj = strtotime(date('Ymd',$t+24*3600));
 
- 				$dlz = $this->fullorder->find_all("dtime >= ".$ct." and dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'budget,shouldmoney,shop,number,refundy,budget,email,refundy');
 
- 				$smt = $this->fullordersmt->find_all("dtime >= ".$ct." and dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'budget,shouldmoney,shop,refundy,userid,budget,refundy');
 
- 				$tt = $this->fullordertt->find_all("state != 217 and dtime >= ".$ct." and dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'budget,shouldmoney,shop,number,refundy,budget,email,refundy');
 
- 				
 
- 				$ab[] = $dlz;
 
- 				//数量及金额开始
 
- 				$dlznum[] = count($dlz);
 
- 				$smtnum[] = count($smt);
 
- 				$ttnum[] = count($smt);
 
- 				$dlzm = sprintf("%01.2f",array_sum(array_column($dlz,'shouldmoney')));
 
- 				$smtm = sprintf("%01.2f",array_sum(array_column($smt,'shouldmoney')));
 
- 				$ttm = sprintf("%01.2f",array_sum(array_column($tt,'shouldmoney')));
 
- 				
 
- 				/**
 
- 				//提出退款关闭等信息的实收金额
 
- 				$dlzmss = sprintf("%01.2f",array_sum(array_column($dlz,'refundy')));
 
- 				$smtmss = sprintf("%01.2f",array_sum(array_column($smt,'refundy')));
 
- 				//提出退款关闭等信息的实收金额
 
- 				**/
 
- 				
 
- 				//实收金额
 
- 				$dlzmss = sprintf("%01.2f",array_sum(array_column($dlz,'budget')));
 
- 				$smtmss = sprintf("%01.2f",array_sum(array_column($smt,'budget')));
 
- 				$ttmss = sprintf("%01.2f",array_sum(array_column($tt,'budget')));
 
- 				//实收金额
 
- 				
 
- 				//补/退原额
 
- 				$dlzbty = sprintf("%01.2f",array_sum(array_column($dlz,'refundy')));
 
- 				$smtbty = sprintf("%01.2f",array_sum(array_column($smt,'refundy')));
 
- 				$ttbty = sprintf("%01.2f",array_sum(array_column($tt,'refundy')));
 
- 				//补/退原额
 
- 				
 
- 				$dlzmoney[] = $dlzm;
 
- 				$smtmoney[] = $smtm;
 
- 				$ttmoney[] = $ttm;
 
- 				$dlzsl += count($dlz);
 
- 				$dlzje += $dlzm;
 
- 				$smtsl += count($smt);
 
- 				$smtje += $smtm;
 
- 				$ttsl += count($tt);
 
- 				$ttje += $ttm;
 
- 				
 
- 				/**
 
- 				//减去的实收金额
 
- 				$dlzssje += $dlzm+$dlzmss;
 
- 				$smtssje += $smtm+$smtmss;
 
- 				**/
 
- 				
 
- 				//实收和补/退
 
- 				$dlzssje += $dlzmss+$dlzbty;
 
- 				$smtssje += $smtmss+$smtbty;
 
- 				$ttssje += $ttmss+$ttbty;
 
- 				
 
- 				//数量及金额结束
 
- 				$sd = array_merge($dlz,$smt,$tt);
 
- 				foreach ($sd as $v) 
 
- 		        {
 
- 					if(isset($shopdata[$v['shop']]))
 
- 					{
 
- 						$shopdata[$v['shop']]['num'] += 1;
 
- 						$shopdata[$v['shop']]['money'] += $v['shouldmoney'];
 
- 						$shopdata[$v['shop']]['tmoney'] += $v['budget']+$v['refundy'];
 
- 					   
 
- 					}
 
-                 }
 
- 				}
 
- 				else if ($n > 13 && $i <= $n/2)
 
- 				{
 
- 				$t = $usat-($n*24*60*60)+($i*24*60*60);
 
- 				$timeold[] = date('m-d',$t);
 
- 				$ct = strtotime(date('Ymd',$t));
 
- 				$ctj = strtotime(date('Ymd',$t+24*3600));
 
- 				$dlz = $this->fullorder->find_all("(".rtrim($fgshop,'or').") and dtime >= ".$ct." and dtime <= ".$ctj.$where,'budget,shouldmoney,shop');
 
- 				$smt = $this->fullordersmt->find_all("(".rtrim($fgshop,'or').") and dtime >= ".$ct." and dtime <= ".$ctj.$where,'budget,shouldmoney,shop');
 
- 				$tt = $this->fullordertt->find_all("state != 217 and (".rtrim($fgshop,'or').") and dtime >= ".$ct." and dtime <= ".$ctj.$where,'budget,shouldmoney,shop');
 
- 				//数量及金额开始
 
- 				$dlzm = sprintf("%01.2f",array_sum(array_column($dlz,'shouldmoney')));
 
- 				$smtm = sprintf("%01.2f",array_sum(array_column($smt,'shouldmoney')));
 
- 				$ttm = sprintf("%01.2f",array_sum(array_column($tt,'shouldmoney')));
 
- 				$dlzmoneyb[] = $dlzm;
 
- 				$smtmoneyb[] = $smtm;
 
- 				$ttmoneyb[] = $ttm;
 
- 				//数量及金额结束
 
- 				}
 
- 		    }
 
- 			foreach ($shopdata as $k=>$v) 
 
- 		    {
 
- 				$sn = $this->shop->read($k);
 
- 				$shopdata[$k]['money'] = sprintf("%01.2f",$v['money']).'$';
 
- 				$shopdata[$k]['tmoney'] = sprintf("%01.2f",$v['tmoney']).'$';
 
- 				$shopdata[$k]['bl'] = ($v['num']=='0')?'0$':round($v['money']/$v['num'],2).'$';
 
- 				$shopdata[$k]['name'] = $sn['shopname'];
 
- 				$shopdata[$k]['b'] = $sn['type'];
 
- 				$shopdata[$k]['id'] = $sn['id'];
 
-             }
 
- 			$shopdata = array_values($shopdata);
 
- 			//$sycp=array();
 
- 			/**
 
- 			//根据所选时间产品排行开始
 
- 			$dlzlist = $this->fullorder->find_all("dtime >= '".($tm-$zdt)."' and dtime <= '".$tm."' and (".rtrim($fgshop,'or').")".$where,'whlabel,fpdata');
 
- 			$smtlist = $this->fullordersmt->find_all("dtime >= '".($tm-$zdt)."' and dtime <= '".$tm."' and (".rtrim($fgshop,'or').")".$where,'whlabel,fpdata');
 
- 			**/
 
- 			/**
 
- 			//昨日产品排行开始
 
- 			$dlzlist = $this->fullorder->find_all("fpdata != '' and dtime >= '".strtotime(date("Ymd",time()-86400))."' and dtime <= '".strtotime(date("Ymd",time()))."' and (".rtrim($fgshop,'or').")".$where,'whlabel,fpdata');
 
- 			$smtlist = $this->fullordersmt->find_all("fpdata != '' and dtime >= '".strtotime(date("Ymd",time()-86400))."' and dtime <= '".strtotime(date("Ymd",time()))."' and (".rtrim($fgshop,'or').")".$where,'whlabel,fpdata');
 
- 			$rows = array_merge($dlzlist,$smtlist);
 
- 			foreach ($rows as $v) 
 
- 		    {
 
- 				$number = explode('|',trim($v['whlabel'],'|'));
 
- 				$or = explode(';',trim($v['fpdata'],';'));
 
- 				$i=0;
 
- 				foreach ($or as $va) 
 
- 		        {
 
- 					$ord = explode('|',$va);
 
- 					$orod = explode(',',$ord[0]);
 
- 					$numberod = explode('-',$number[$i]);
 
- 					if(!isset($orod[1]))
 
- 					{
 
- 						continue;
 
- 					}
 
- 					if(isset($sycp[$orod[1]]) && isset($numberod[1]))
 
- 					{
 
- 						//$sycp[$orod[1]][0] += 1;//统计多少单
 
- 						$sycp[$orod[1]][0] += $numberod[1];//统计多少条
 
- 						$sycp[$orod[1]][1] += 0;//价格
 
- 					}
 
- 					else
 
- 					{
 
- 						if(isset($numberod[1]))
 
- 						{
 
- 						    $typeclass = $this->typeclass->read($orod['0']);
 
- 						    $sycp[$orod[1]] = array($numberod[1],0,str_replace($typeclass['title'].' ','',$ord[1]));
 
- 						}
 
- 					}
 
- 					$i++;
 
- 				}
 
- 			}
 
- 			arsort($sycp);
 
- 			$sycp = array_values($sycp);
 
- 		    $sycp = array_slice($sycp,0,10);
 
- 			//产品排行结束
 
- 			**/
 
- 			//当时实时数据结束
 
- 			echo @json_encode(array('time'=>$time,'timeold'=>$timeold,'smtnum'=>$smtnum,'ttnum'=>$ttnum,'dlznum'=>$dlznum,'smtmoney'=>$smtmoney,'ttmoney'=>$ttmoney,'dlzmoney'=>$dlzmoney,'smtmoneyb'=>$smtmoneyb,'ttmoneyb'=>$ttmoneyb,'dlzmoneyb'=>$dlzmoneyb,'dlzsl'=>$dlzsl,'dlzje'=>number_format($dlzje,2),'dlzssje'=>number_format($dlzssje,2),'smtsl'=>$smtsl,'ttsl'=>$ttsl,'smtje'=>number_format($smtje,2),'ttje'=>number_format($ttje,2),'smtssje'=>number_format($smtssje,2),'ttssje'=>number_format($ttssje,2),'zje'=>number_format($dlzje+$smtje+$ttje,2),'zsl'=>$dlzsl+$smtsl+$ttsl,'shopdata'=>$shopdata,'success'=>true));exit;//,'sycp'=>$sycp昨日产品数据
 
- 			}
 
- 		}
 
- 		if(isset($post['sstime']))  
 
- 		{
 
- 			$shop = $this->input->post('shop',true);
 
- 			$zdtime = $usat;
 
- 			//当时实时数据开始
 
- 			if(!$shop)
 
- 			{
 
- 			    $sssl = $this->fullorder->find_all("(".rtrim($fgshop,'or').") and dtime >= ".$zdtime." and dtime <= ".strtotime(date('Ymd',$usat+24*3600)).$where,'budget,shouldmoney');
 
- 			    $ssje = $this->fullordersmt->find_all("(".rtrim($fgshop,'or').") and dtime >= ".$zdtime." and dtime <= ".strtotime(date('Ymd',$usat+24*3600)).$where,'budget,shouldmoney');
 
- 				$tje = $this->fullordertt->find_all("state != 217 and (".rtrim($fgshop,'or').") and dtime >= ".$zdtime." and dtime <= ".strtotime(date('Ymd',$usat+24*3600)).$where,'budget,shouldmoney');
 
- 			    $sssldlz = count($sssl);
 
- 			    $ssslsmt = count($ssje);
 
- 				$sssltt = count($tje);
 
- 			    $ssjedlz = sprintf("%01.2f",array_sum(array_column($sssl,'budget')));
 
- 			    $ssjesmt = sprintf("%01.2f",array_sum(array_column($ssje,'budget')));
 
- 				$ssjett= sprintf("%01.2f",array_sum(array_column($tje,'budget')));
 
- 				$sssl = $sssldlz+$ssslsmt+$sssltt;
 
- 				$ssje = $ssjedlz+$ssjesmt+$ssjett;
 
- 			}
 
- 			else
 
- 			{
 
- 				$sp = $this->shop->read($shop);
 
- 				$fu = ($sp['type']=='269')?'fullorder':'fullordersmt';
 
- 				$ss = $this->$fu->find_all("dtime >= ".$zdtime." and dtime <= ".strtotime(date('Ymd',$usat+24*3600))." and shop = '".$shop."'",'budget,shouldmoney');
 
- 				$sssl = count($ss);
 
- 				$ssje = sprintf("%01.2f",array_sum(array_column($ss,'budget')));
 
- 			}
 
- 			echo @json_encode(array('sstime'=>date('m-d H:i',time()),'sssl'=>$sssl,'ssje'=>sprintf("%.2f",$ssje),'success'=>true));exit;
 
- 		}
 
- 		//店铺产品详情
 
- 		if(isset($post['id']))  
 
- 		{
 
- 			$tm += 24*3600;
 
- 			$gshtime = date('Y-m-d 0:0:0',time());
 
- 			$gshtime = strtotime($gshtime)+24*60*60;
 
- 			$dpxq=array();
 
- 			$id = $this->input->post('id',true);
 
- 			$xqtime = $this->input->post('xqtime',true);
 
- 			$xqshop = $this->shop->read($id);
 
- 			if($xqshop['type']=="269")
 
- 			{
 
- 				$sid = 'fullorder';
 
- 			}
 
- 			else if($xqshop['type']=="270")
 
- 			{
 
- 				$sid = 'fullordersmt';
 
- 			}
 
- 			else if($xqshop['type']=="1514")
 
- 			{
 
- 				$sid = 'fullordertt';
 
- 			}
 
- 			if($xqtime > 345600)
 
- 			{
 
- 				$rows = $this->$sid->find_all("shop = '".$id."' and dtime >= '".($gshtime-$xqtime)."' and dtime <= '".($gshtime+24*60*60)."'",'whlabel,fpdata,number');
 
- 			}
 
- 			else
 
- 			{
 
- 			    $rows = $this->$sid->find_all("shop = '".$id."' and dtime >= '".($gshtime-$xqtime)."' and dtime <= '".($gshtime+24*60*60-$xqtime)."'",'whlabel,fpdata,number');
 
- 			}
 
- 			foreach ($rows as $v) 
 
- 		    {
 
- 				$or = explode('|',ltrim($v['whlabel'],'|'));
 
- 				for($i=0;$i<count($or);$i++)
 
- 				{
 
- 					$orod = explode('-',$or[$i]);
 
- 					if($orod[0] == '')
 
- 					{
 
- 						continue;
 
- 					}
 
- 					if(isset($dpxq[$orod[0]]))
 
- 					{
 
- 						$dpxq[$orod[0]][0] += $orod[1];//统计多少条
 
- 						//$dpxq[$orod[0]][0] += 1;//统计多少单
 
- 						$dpxq[$orod[0]][1] .= $v['number'].';';//价格
 
- 					}
 
- 					else
 
- 					{
 
- 						$oo = explode(';',rtrim($v['fpdata'],';'));
 
- 						@$ro = explode('|',$oo[$i]);
 
- 						if(isset($ro[1]))
 
- 						{
 
- 						   $dpxq[$orod[0]] = array($orod[1],$v['number'].';',$ro[1]);//统计多少条
 
- 						   //$dpxq[$orod[0]] = array(1,0,$ro[1]);//统计多少单
 
- 						}
 
- 					}
 
- 				}
 
- 			}
 
- 			$dpxq = array_values($dpxq);
 
- 			arsort($dpxq);
 
- 			 $dpxq = array_slice($dpxq,0,9999);
 
- 			echo @json_encode(array('dpxq'=>$dpxq,'success'=>true));exit;
 
- 		}
 
- 		$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
 
- 		$this->data['wlshop'] = $wlshop;
 
- 		$dr = $usat;
 
- 		$this->data['dr'] = array(date("m-d",$dr),date("m-d",$dr-24*3600),date("m-d",$dr-2*24*3600),date("m-d",$dr-3*24*3600));
 
- 		$this->_Template('phone/p_user_statistics',$this->data);
 
- 	}
 
- 	
 
- 	/**
 
- 	public function super_unique($array,$key)//多维删除重复
 
-     {
 
-        $temp_array = array();
 
-        foreach ($array as &$v) {
 
-            if (!isset($temp_array[$v[$key]]))
 
- 		   {
 
-                $temp_array[$v[$key]] =& $v;
 
- 		   }
 
-        }
 
-        $array = array_values($temp_array);
 
-        return $array;
 
-     }
 
- 	**/
 
- 	
 
- 	public function _usatime()
 
- 	{
 
- 		date_default_timezone_set("Etc/GMT+8");
 
- 		return time();
 
- 	}
 
- 	//数据
 
- 	public function _rows()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['shop']))  
 
- 		{
 
- 			$shop = $this->input->post('shop',true);
 
-             $data = $this->shop->find_all('1=1');
 
- 			$list = array();
 
- 			foreach ($data as $key=>$value) 
 
- 		    {
 
- 				$t = $this->typeclass->read($value['type']);
 
- 				$list[] = array('id'=>$value['id'],'title'=>$value['shopname'].' - '.$t['title']);
 
-             }
 
- 			$num = array();
 
- 			if($shop != "null")
 
- 			{
 
- 			    $num = $this->user->read($shop);//找出内容
 
- 				if($num['shop'])
 
- 				{
 
- 			        $num = explode('|',trim($num['shop'],'|'));//数组化内容
 
- 				}
 
- 				else
 
- 				{
 
- 					$num = array();
 
- 				}
 
- 			}
 
- 		    echo json_encode(array('msg'=>($list),'num'=>($num),'success'=>true));
 
- 		}
 
- 		if(isset($post['excelshop']))  
 
- 		{
 
- 			$excelshop = $this->input->post('excelshop',true);
 
-             $data = $this->shop->find_all('1=1');
 
- 			$list = array();
 
- 			foreach ($data as $key=>$value) 
 
- 		    {
 
- 				$t = $this->typeclass->read($value['type']);
 
- 				$list[] = array('id'=>$value['id'],'title'=>$value['shopname'].' - '.$t['title']);
 
-             }
 
- 			$num = array();
 
- 			if($excelshop != "null")
 
- 			{
 
- 			    $num = $this->user->read($excelshop);//找出内容
 
- 				if($num['excelshop'])
 
- 				{
 
- 			        $num = explode('|',trim($num['excelshop'],'|'));//数组化内容
 
- 				}
 
- 				else
 
- 				{
 
- 					$num = array();
 
- 				}
 
- 			}
 
- 		    echo json_encode(array('msg'=>($list),'num'=>($num),'success'=>true));
 
- 		}
 
- 		if(isset($post['purchase']))  
 
- 		{
 
- 			$purchase = $this->input->post('purchase',true);
 
-             $data = $this->purchase->find_all('1=1');
 
- 			$list = array();
 
- 			foreach ($data as $key=>$value) 
 
- 		    {
 
- 				$list[] = array('id'=>$value['id'],'title'=>$value['title']);
 
-             }
 
- 			$num = array();
 
- 			if($purchase != "null")
 
- 			{
 
- 			    $num = $this->user->read($purchase);//找出内容
 
- 				if($num['purchase'])
 
- 				{
 
- 			        $num = explode('|',trim($num['purchase'],'|'));//数组化内容
 
- 				}
 
- 				else
 
- 				{
 
- 					$num = array();
 
- 				}
 
- 			}
 
- 		    echo json_encode(array('msg'=>($list),'num'=>($num),'success'=>true));
 
- 		}
 
- 		if(isset($post['staff']))  
 
- 		{
 
- 			$staff = $this->input->post('staff',true);
 
-             $data = $this->staff->find_all('1=1');
 
- 			$list = array();
 
- 			foreach ($data as $key=>$value) 
 
- 		    {
 
- 				$list[] = array('id'=>$value['id'],'title'=>$value['name']);
 
-             }
 
- 			$num = array();
 
- 			if($staff != "null")
 
- 			{
 
- 			    $num = $this->user->read($staff);//找出内容
 
- 				if($num['staff'])
 
- 				{
 
- 			        $num = explode('|',trim($num['staff'],'|'));//数组化内容
 
- 				}
 
- 				else
 
- 				{
 
- 					$num = array();
 
- 				}
 
- 			}
 
- 		    echo json_encode(array('msg'=>($list),'num'=>($num),'success'=>true));
 
- 		}
 
- 		if(isset($post['warehouse']))  
 
- 		{
 
- 			$warehouse = $this->input->post('warehouse',true);
 
-             $data = $this->warehouse->find_all('1=1');
 
- 			$list = array();
 
- 			foreach ($data as $key=>$value) 
 
- 		    {
 
- 				$list[] = array('id'=>$value['id'],'title'=>$value['title']);
 
-             }
 
- 			$num = array();
 
- 			if($warehouse != "null")
 
- 			{
 
- 			    $num = $this->user->read($warehouse);//找出内容
 
- 				if($num['warehouse'])
 
- 				{
 
- 			        $num = explode('|',trim($num['warehouse'],'|'));//数组化内容
 
- 				}
 
- 				else
 
- 				{
 
- 					$num = array();
 
- 				}
 
- 			}
 
- 		    echo json_encode(array('msg'=>($list),'num'=>($num),'success'=>true));
 
- 		}
 
- 		if(isset($post['transfer']))  
 
- 		{
 
- 			$transfer = $this->input->post('transfer',true);
 
-             $data = $this->transfer->find_all('1=1');
 
- 			$list = array();
 
- 			foreach ($data as $key=>$value) 
 
- 		    {
 
- 				$list[] = array('id'=>$value['id'],'title'=>$value['title']);
 
-             }
 
- 			$num = array();
 
- 			if($transfer != "null")
 
- 			{
 
- 			    $num = $this->user->read($transfer);//找出内容
 
- 				if($num['transfer'])
 
- 				{
 
- 			        $num = explode('|',trim($num['transfer'],'|'));//数组化内容
 
- 				}
 
- 				else
 
- 				{
 
- 					$num = array();
 
- 				}
 
- 			}
 
- 		    echo json_encode(array('msg'=>($list),'num'=>($num),'success'=>true));
 
- 		}
 
-     }
 
- 	
 
- 	public function _shopfx()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
- 		if(isset($post['time']))  
 
- 		{
 
- 			$time = $this->input->post('time',true);
 
- 			$t = strtotime(date("Ymd",time()+24*3600));//明天0点
 
- 			$shop = $this->shop->find_all("type = 269 and tb = 1 and id != 22 and id != 28 and id != 29 and id != 30");
 
- 			$sid = '';
 
- 			foreach ($shop as $value) 
 
- 		    {
 
- 				$sid .= " shop = ".$value['id']." or";
 
- 			}
 
- 			$sid = " and (".rtrim($sid,'or').")";
 
- 			$znum = $this->fullorder->find_count("dtime > '".($t-$time*24*3600)."' and dtime < '".$t."'".$sid);
 
- 			$data = array();$list = array();
 
- 			$color = array('0'=>'#30546c','1'=>'#61a0a8','2'=>'#c23531','3'=>'#d48265','4'=>'#546570','5'=>'#749f83','6'=>'#bda29a','7'=>'#6e7074','8'=>'#546570');
 
- 			$j = 0;
 
- 			$zt = array(7=>1,30=>2);
 
- 			foreach ($shop as $v) 
 
- 		    {
 
- 				$d = $this->fullorder->find_count("shop = '".$v['id']."' and dtime > '".($t-$time*24*3600)."' and dtime < '".$t."' and (state = '207' or state = '216')");
 
- 				$wd = $this->allocation->read($zt[$time]);
 
- 				$n = json_decode($wd['content'],true);
 
- 				$bfb = ($d==0)?0:round(($d / $znum) * 100, 2);
 
- 				$data[] = array('value'=>$bfb,'name'=>$v['shopname'].' '.$bfb."%",'itemStyle'=>array('color'=>$color[$j]));
 
- 				$n[$v['id']][] = $this->fullorder->find_count("shop = '".$v['id']."' and gtime = '".date("Ymd",time())."' and (state = '207' or state = '216')");
 
- 				$t_list = array();
 
- 				for($i=0;$i<$time;$i++)
 
- 				{
 
- 					$t_list[] = date("m-d",time()-($i*24*3600));
 
- 				}
 
- 				$list[] = array('name'=>$v['shopname'],'type'=>'bar','data'=>$n[$v['id']],'label'=>array('show'=>true,'position'=>'right'),'itemStyle'=>array('color'=>$color[$j]),'barWidth'=>round((1/(count($shop)+2)) * 100, 2).'%');
 
- 				$j++;
 
-             }
 
- 			$list = (array_reverse($list));
 
- 			 echo json_encode(array('data'=>($data),'list'=>$list,'t'=>(array_reverse($t_list)),'success'=>true));exit;
 
- 			/**
 
- 			$time = $this->input->post('time',true);
 
- 			$t = strtotime(date("Ymd",time()+24*3600));//明天0点
 
- 			$shop = $this->shop->find_all("type = 269 and tb = 1 and id != 22 and id != 28 and id != 29 and id != 30");
 
- 			$sid = '';
 
- 			foreach ($shop as $value) 
 
- 		    {
 
- 				$sid .= " shop = ".$value['id']." or";
 
- 			}
 
- 			$sid = " and (".rtrim($sid,'or').")";
 
- 			$znum = $this->fullorder->find_count("dtime > '".($t-$time*24*3600)."' and dtime < '".$t."'".$sid);
 
- 			$data = array();$list = array();
 
- 			$color = array('0'=>'#30546c','1'=>'#61a0a8','2'=>'#c23531','3'=>'#d48265','4'=>'#546570','5'=>'#749f83','6'=>'#bda29a','7'=>'#6e7074','8'=>'#546570');
 
- 			$j = 0;
 
- 			foreach ($shop as $v) 
 
- 		    {
 
- 				$d = $this->fullorder->find_count("shop = '".$v['id']."' and dtime > '".($t-$time*24*3600)."' and dtime < '".$t."' and (state = '207' or state = '216')");
 
- 				$bfb = ($d==0)?0:round(($d / $znum) * 100, 2);
 
- 				$data[] = array('value'=>$bfb,'name'=>$v['shopname'].' '.$bfb."%",'itemStyle'=>array('color'=>$color[$j]));
 
- 				$n = array();$t_list = array();
 
- 				for($i=0;$i<$time;$i++)
 
- 				{
 
- 					if($i == 0)
 
- 					{
 
- 						$s = date("Ymd",time());
 
- 					}
 
- 					else
 
- 					{
 
- 						$s = date("Ymd",time()-($i*24*3600));
 
- 					}
 
- 					$t_list[] = date("m-d",time()-($i*24*3600));
 
- 					$n[] = $this->fullorder->find_count("shop = '".$v['id']."' and gtime = '".$s."' and (state = '207' or state = '216')");
 
- 				}
 
- 				$list[] = array('name'=>$v['shopname'],'type'=>'bar','data'=>array_reverse($n),'label'=>array('show'=>true,'position'=>'right'),'itemStyle'=>array('color'=>$color[$j]),'barWidth'=>round((1/(count($shop)+2)) * 100, 2).'%');
 
- 				$j++;
 
-             }
 
- 			$list = (array_reverse($list));
 
- 			 echo json_encode(array('data'=>($data),'list'=>$list,'t'=>(array_reverse($t_list)),'success'=>true));exit;
 
- 			 **/
 
- 		}
 
- 		$this->_Template('phone/p_user_shopfx',$this->data);
 
- 	}
 
- 	
 
- 	public function _shopfxlist()
 
- 	{
 
- 		$t = strtotime(date("Ymd",time()));//今天0点
 
- 		$shop = $this->shop->find_all("type = 269 and tb = 1 and id != 22 and id != 28 and id != 29 and id != 30");
 
- 		$sid = '';
 
- 		foreach ($shop as $value) 
 
- 		{
 
- 			$sid .= " shop = ".$value['id']." or";
 
- 		}
 
- 		$sid = " and (".rtrim($sid,'or').")";
 
- 		$zt = array(7,30);
 
- 		$this->db->trans_begin();
 
- 		foreach ($zt as $key=>$time) 
 
- 		{
 
- 			$data = array();$list = array();
 
- 			foreach ($shop as $v) 
 
- 		    {
 
- 				$n = array();$t_list = array();
 
- 				for($i=1;$i<$time;$i++)
 
- 				{
 
- 					if($i == 0)
 
- 					{
 
- 						$s = date("Ymd",time());
 
- 					}
 
- 					else
 
- 					{
 
- 						$s = date("Ymd",time()-($i*24*3600));
 
- 					}
 
- 					$t_list[] = date("m-d",time()-($i*24*3600));
 
- 					$n[] = $this->fullorder->find_count("shop = '".$v['id']."' and gtime = '".$s."' and (state = '207' or state = '216')");
 
- 				}
 
- 				$list[$v['id']] = array_reverse($n);
 
- 			}
 
- 			$this->allocation->save(array('content'=>json_encode($list)),$key+1);
 
-         }
 
- 		if ($this->db->trans_status() === FALSE)
 
-         {
 
- 			$this->db->trans_rollback();
 
- 			echo 'orver';
 
- 		}
 
- 		else
 
- 		{
 
- 			$this->db->trans_commit();
 
- 			echo 'ok';
 
- 		}
 
- 	}
 
- 	
 
- 	public function _apple()
 
- 	{
 
- 		$this->_Template('phone/p_user_apple',$this->data);
 
- 	}
 
- 	
 
- 	//退出
 
- 	public function _tc()
 
- 	{
 
- 		$this->session->sess_destroy();
 
- 		header("Location:/");
 
- 	}
 
- 	
 
- 	public function _tjadd()
 
- 	{
 
- 		$pdtime = date('Y-m-d-H',time());
 
- 		//if(is_file("./data/tj/".$pdtime.".txt"))
 
- 		if(is_file("./data/tj/".$pdtime.".txt"))
 
- 		{
 
- 			$myfile = fopen("./data/tj/".$pdtime.".txt", "r") or die("Unable to open file!");
 
-             $bc = fread($myfile,filesize("./data/tj/".$pdtime.".txt"));
 
-             fclose($myfile);
 
- 			$bc = json_decode($bc,true);
 
- 			$zzt = array($bc['zzt'][0],$bc['zzt'][1]);
 
- 		}
 
- 		else
 
- 		{
 
- 		/** 暂时不需要了
 
- 		//柱状图数据 
 
- 		$i = 0;
 
- 		$data = array();$sndata1 = array();$sndata2 = array();$sndata3 = array();
 
- 		$sj = array('01','02','03','04','05','06','07','08','09','10','11','12');
 
- 		foreach ($sj as $k=>$v) 
 
- 		{
 
- 			$i++;
 
- 			$dlz1 = $this->fullorder->find_all("gtime > '".date("Y").$v."00' and gtime < '".date("Y").$v."32'",'shouldmoney');
 
- 			$smt1 = $this->fullordersmt->find_all("gtime > '".date("Y").$v."00' and gtime < '".date("Y").$v."32'",'shouldmoney');
 
- 			$m1 = sprintf("%01.2f",array_sum(array_column($dlz1,'shouldmoney'))+array_sum(array_column($smt1,'shouldmoney')));
 
- 				
 
- 			$dlz2 = $this->fullorder->find_all("gtime > '".(date("Y")-1).$v."00' and gtime < '".(date("Y")-1).$v."32'",'shouldmoney');
 
- 			$smt2 = $this->fullordersmt->find_all("gtime > '".(date("Y")-1).$v."00' and gtime < '".(date("Y")-1).$v."32'",'shouldmoney');
 
- 			$m2 = sprintf("%01.2f",array_sum(array_column($dlz2,'shouldmoney'))+array_sum(array_column($smt2,'shouldmoney')));
 
- 				
 
- 			$dlz3 = $this->fullorder->find_all("gtime > '".(date("Y")-2).$v."00' and gtime < '".(date("Y")-2).$v."32'",'shouldmoney');
 
- 			$smt3 = $this->fullordersmt->find_all("gtime > '".(date("Y")-2).$v."00' and gtime < '".(date("Y")-2).$v."32'",'shouldmoney');
 
- 			$m3 = sprintf("%01.2f",array_sum(array_column($dlz3,'shouldmoney'))+array_sum(array_column($smt3,'shouldmoney')));
 
- 				
 
- 			$sndata1[$i] = $m3;
 
- 			$sndata2[12+$i] = $m2;
 
- 			$sndata3[24+$i] = $m1;
 
- 			$data[] = array($v,$m1,$m2,$m3);
 
- 		}
 
- 		$sndata = array_merge($sndata1,$sndata2,$sndata3);
 
- 		$zzt = array($data,$sndata);
 
- 		//柱状图结束
 
- 		**/
 
- 		}
 
- 		
 
- 		//详情内容
 
- 		$dt = 0;
 
- 		
 
- 			$user = $this->user->get_api($_SESSION['api']);
 
- 			$usp = $user;
 
- 		    $fgshop = "";$sid = "";
 
- 		    $user = explode('|',trim($user['shop'],'|'));
 
- 			foreach ($user as $value) 
 
- 		    {
 
- 				$fgshop .= " shop = ".$value." or";
 
- 				$sid .= " id = ".$value." or";
 
- 			}
 
- 		$tm = strtotime(date("Ymd"),time());
 
- 		$usat = $tm;
 
- 		//$molist = array('0','1','2d');
 
- 		$molist = array('0','1');
 
- 		$zqtime = array(259200,345600,691200,2678400,7862400,31622400);
 
- 		
 
- 		//time开始
 
- 		$zqtdata = array();
 
- 		foreach ($molist as $vval) 
 
- 		{
 
- 			$where = "";
 
- 			$source = $vval;
 
- 			if($source == '2d')
 
- 			{
 
- 				$where = " and source >= '2'";
 
- 			}
 
- 			else if($source != '0')
 
- 			{
 
- 			    $where = " and source = '$source'";
 
- 			}
 
- 		foreach ($zqtime as $value) 
 
- 		{
 
- 			$zdt = $value;
 
- 			$k = $zdt;
 
- 			$tab = 1;
 
- 			//$start = '2018-10-15';
 
- 			//$end = '2018-11-26';
 
- 			//$tim = strtotime($start);
 
- 			//$day = $time/(3600*24);
 
- 			if($tab == '1')
 
- 			{
 
- 				if($zdt >= 691200)
 
- 				{
 
- 					$k = $usat-$k-$k;
 
- 			        $j = $usat;
 
- 				    $n = ($j-$k)/(24*3600);
 
- 				}
 
- 				else
 
- 				{
 
- 					$n = 2;
 
- 			        $usat = strtotime(date("Ymd"),time())-$k+2*24*3600;
 
- 				}
 
- 			}
 
- 			else
 
- 			{
 
- 			    $timedata = explode('|',$zdt);
 
- 				$ktime = strtotime($timedata[0]);
 
- 			    $jtime = strtotime($timedata[1]);
 
- 				$ktime = $ktime-($jtime-$ktime);
 
- 				$k = $ktime;
 
- 			    $j = $jtime;
 
- 				$n = ($j-$k)/(24*3600);
 
- 				$usat = $jtime;
 
- 				$tm = $jtime;
 
- 				$zdt = $jtime-$ktime;
 
- 			}
 
- 		    $time=array();$timeold=array();$stime=array();$dlznum = array();$smtnum = array();;$ttnum = array();$ymoney = array();$money = array();$dlzmoney = array();$smtmoney=array();$ttmoney=array();
 
- 			$dlzmoneyb=array();$smtmoneyb=array();$ttmoneyb=array();
 
- 			$dlzsl=0;$dlzje=0;$dlzssje=0;$smtsl=0;$smtje=0;$smtssje=0;$ttsl=0;$ttje=0;$ttssje=0;$shopdata = array();
 
- 			$ys = $this->shop->find_all("type != '0' and id != '16' and id != '17' and id != '18' and id != '19' and id != '20' and id != '12' and id != '13' and id != '8' and id != '10' and id != '11' and id != '13' and id != '22' and id != '23' and id != '24' and id != '25' and id != '26' and id != '9' and id != '15' and id != '27' and id != '28' and id != '29' and id != '30' and id != '21' and id != '34'");
 
- 			foreach ($ys as $v) 
 
- 		    {
 
- 				$shopdata[$v['id']] = array('num'=>0,'money'=>0,'tmoney'=>0,'fdl'=>0,'chl'=>0);
 
- 			}
 
- 		    for($i=1;$i<$n;$i++)
 
- 		    {
 
- 				//近7天时间
 
- 				//$t = ($usat-16*3600)-($n*24*60*60)+($i*24*60*60);
 
- 				if($n > 13 && $i > $n/2 || $n < 14)
 
- 				{
 
- 				    $t = $usat-($n*24*60*60)+($i*24*60*60);
 
- 			        $time[] = date('m-d',$t);
 
- 				    $ct = strtotime(date('Ymd',$t));
 
- 				    $ctj = strtotime(date('Ymd',$t+24*3600));
 
- 				    $dlz = $this->fullorder->find_all("dtime >= ".$ct." and dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'budget,shouldmoney,shop,number,refundy,budget,email,refundy');
 
- 				    $smt = $this->fullordersmt->find_all("dtime >= ".$ct." and dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'budget,shouldmoney,shop,refundy,userid,budget,refundy');
 
- 				    $tt = $this->fullordertt->find_all("state != 217 and dtime >= ".$ct." and dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'budget,shouldmoney,shop,number,refundy,budget,email,refundy');
 
- 				
 
- 				    $ab[] = $dlz;
 
- 				    //数量及金额开始
 
- 				    $dlznum[] = count($dlz);
 
- 				    $smtnum[] = count($smt);
 
- 				    $ttnum[] = count($smt);
 
- 				    $dlzm = sprintf("%01.2f",array_sum(array_column($dlz,'shouldmoney')));
 
- 				    $smtm = sprintf("%01.2f",array_sum(array_column($smt,'shouldmoney')));
 
- 				    $ttm = sprintf("%01.2f",array_sum(array_column($tt,'shouldmoney')));
 
- 				
 
- 				    /**
 
- 				    //提出退款关闭等信息的实收金额
 
- 				    $dlzmss = sprintf("%01.2f",array_sum(array_column($dlz,'refundy')));
 
- 				    $smtmss = sprintf("%01.2f",array_sum(array_column($smt,'refundy')));
 
- 				    //提出退款关闭等信息的实收金额
 
- 				    **/
 
- 				
 
- 				    //实收金额
 
- 				    $dlzmss = sprintf("%01.2f",array_sum(array_column($dlz,'budget')));
 
- 				    $smtmss = sprintf("%01.2f",array_sum(array_column($smt,'budget')));
 
- 				    $ttmss = sprintf("%01.2f",array_sum(array_column($tt,'budget')));
 
- 				    //实收金额
 
- 				
 
- 				    //补/退原额
 
- 				    $dlzbty = sprintf("%01.2f",array_sum(array_column($dlz,'refundy')));
 
- 				    $smtbty = sprintf("%01.2f",array_sum(array_column($smt,'refundy')));
 
- 				    $ttbty = sprintf("%01.2f",array_sum(array_column($tt,'refundy')));
 
- 				    //补/退原额
 
- 				
 
- 				    $dlzmoney[] = $dlzm;
 
- 				    $smtmoney[] = $smtm;
 
- 				    $ttmoney[] = $ttm;
 
- 				    $dlzsl += count($dlz);
 
- 				    $dlzje += $dlzm;
 
- 				    $smtsl += count($smt);
 
- 				    $smtje += $smtm;
 
- 				    $ttsl += count($tt);
 
- 				    $ttje += $ttm;
 
- 				
 
- 				    /**
 
- 				    //减去的实收金额
 
- 				    $dlzssje += $dlzm+$dlzmss;
 
- 				    $smtssje += $smtm+$smtmss;
 
- 				    **/
 
- 				
 
- 				    //实收和补/退
 
- 				    $dlzssje += $dlzmss+$dlzbty;
 
- 				    $smtssje += $smtmss+$smtbty;
 
- 				    $ttssje += $ttmss+$ttbty;
 
- 				
 
- 				    //数量及金额结束
 
- 				    $sd = array_merge($dlz,$smt,$tt);
 
- 				    foreach ($sd as $v) 
 
- 		            {
 
- 					    if(isset($shopdata[$v['shop']]))
 
- 					    {
 
- 						    $shopdata[$v['shop']]['num'] += 1;
 
- 						    $shopdata[$v['shop']]['money'] += $v['shouldmoney'];
 
- 						    $shopdata[$v['shop']]['tmoney'] += $v['budget']+$v['refundy'];
 
- 					   
 
- 					    }
 
-                     }
 
- 				}
 
- 				else if ($n > 13 && $i <= $n/2)
 
- 				{
 
- 				    $t = $usat-($n*24*60*60)+($i*24*60*60);
 
- 				    $timeold[] = date('m-d',$t);
 
- 				    $ct = strtotime(date('Ymd',$t));
 
- 				    $ctj = strtotime(date('Ymd',$t+24*3600));
 
- 				    $dlz = $this->fullorder->find_all("(".rtrim($fgshop,'or').") and dtime >= ".$ct." and dtime <= ".$ctj.$where,'budget,shouldmoney,shop');
 
- 				    $smt = $this->fullordersmt->find_all("(".rtrim($fgshop,'or').") and dtime >= ".$ct." and dtime <= ".$ctj.$where,'budget,shouldmoney,shop');
 
- 				    $tt = $this->fullordertt->find_all("state != 217 and (".rtrim($fgshop,'or').") and dtime >= ".$ct." and dtime <= ".$ctj.$where,'budget,shouldmoney,shop');
 
- 				    //数量及金额开始
 
- 				    $dlzm = sprintf("%01.2f",array_sum(array_column($dlz,'shouldmoney')));
 
- 				    $smtm = sprintf("%01.2f",array_sum(array_column($smt,'shouldmoney')));
 
- 				    $ttm = sprintf("%01.2f",array_sum(array_column($tt,'shouldmoney')));
 
- 				    $dlzmoneyb[] = $dlzm;
 
- 				    $smtmoneyb[] = $smtm;
 
- 				    $ttmoneyb[] = $ttm;
 
- 				//数量及金额结束
 
- 				}
 
- 		    }
 
- 			foreach ($shopdata as $k=>$v) 
 
- 		    {
 
- 				$sn = $this->shop->read($k);
 
- 				$shopdata[$k]['money'] = sprintf("%01.2f",$v['money']).'$';
 
- 				$shopdata[$k]['tmoney'] = sprintf("%01.2f",$v['tmoney']).'$';
 
- 				$shopdata[$k]['bl'] = ($v['num']=='0')?'0$':round($v['money']/$v['num'],2).'$';
 
- 				$shopdata[$k]['name'] = $sn['shopname'];
 
- 				$shopdata[$k]['b'] = $sn['type'];
 
- 				$shopdata[$k]['id'] = $sn['id'];
 
-             }
 
- 			$shopdata = array_values($shopdata);
 
- 			//$sycp=array();
 
- 			/**
 
- 			//根据所选时间产品排行开始
 
- 			$dlzlist = $this->fullorder->find_all("dtime >= '".($tm-$zdt)."' and dtime <= '".$tm."' and (".rtrim($fgshop,'or').")".$where,'whlabel,fpdata');
 
- 			$smtlist = $this->fullordersmt->find_all("dtime >= '".($tm-$zdt)."' and dtime <= '".$tm."' and (".rtrim($fgshop,'or').")".$where,'whlabel,fpdata');
 
- 			**/
 
- 			/**
 
- 			//昨日产品排行开始
 
- 			$dlzlist = $this->fullorder->find_all("fpdata != '' and dtime >= '".strtotime(date("Ymd",time()-86400))."' and dtime <= '".strtotime(date("Ymd",time()))."' and (".rtrim($fgshop,'or').")".$where,'whlabel,fpdata');
 
- 			$smtlist = $this->fullordersmt->find_all("fpdata != '' and dtime >= '".strtotime(date("Ymd",time()-86400))."' and dtime <= '".strtotime(date("Ymd",time()))."' and (".rtrim($fgshop,'or').")".$where,'whlabel,fpdata');
 
- 			$rows = array_merge($dlzlist,$smtlist);
 
- 			foreach ($rows as $v) 
 
- 		    {
 
- 				$number = explode('|',trim($v['whlabel'],'|'));
 
- 				$or = explode(';',trim($v['fpdata'],';'));
 
- 				$i=0;
 
- 				foreach ($or as $va) 
 
- 		        {
 
- 					$ord = explode('|',$va);
 
- 					$orod = explode(',',$ord[0]);
 
- 					$numberod = explode('-',$number[$i]);
 
- 					if(!isset($orod[1]))
 
- 					{
 
- 						continue;
 
- 					}
 
- 					if(isset($sycp[$orod[1]]) && isset($numberod[1]))
 
- 					{
 
- 						//$sycp[$orod[1]][0] += 1;//统计多少单
 
- 						$sycp[$orod[1]][0] += $numberod[1];//统计多少条
 
- 						$sycp[$orod[1]][1] += 0;//价格
 
- 					}
 
- 					else
 
- 					{
 
- 						if(isset($numberod[1]))
 
- 						{
 
- 						    $typeclass = $this->typeclass->read($orod['0']);
 
- 						    $sycp[$orod[1]] = array($numberod[1],0,str_replace($typeclass['title'].' ','',$ord[1]));
 
- 						}
 
- 					}
 
- 					$i++;
 
- 				}
 
- 			}
 
- 			arsort($sycp);
 
- 			$sycp = array_values($sycp);
 
- 		    $sycp = array_slice($sycp,0,10);
 
- 			//产品排行结束
 
- 			**/
 
- 			//当时实时数据结束
 
- 			$zqtdata[$vval][$value] = array('time'=>$time,'timeold'=>$timeold,'smtnum'=>$smtnum,'ttnum'=>$ttnum,'dlznum'=>$dlznum,'smtmoney'=>$smtmoney,'ttmoney'=>$ttmoney,'dlzmoney'=>$dlzmoney,'smtmoneyb'=>$smtmoneyb,'ttmoneyb'=>$ttmoneyb,'dlzmoneyb'=>$dlzmoneyb,'dlzsl'=>$dlzsl,'dlzje'=>number_format($dlzje,2),'dlzssje'=>number_format($dlzssje,2),'smtsl'=>$smtsl,'ttsl'=>$ttsl,'smtje'=>number_format($smtje,2),'ttje'=>number_format($ttje,2),'smtssje'=>number_format($smtssje,2),'ttssje'=>number_format($ttssje,2),'zje'=>number_format($dlzje+$smtje+$ttje,2),'zsl'=>$dlzsl+$smtsl+$ttsl,'shopdata'=>$shopdata,'cs'=>$n,'success'=>true);//,'sycp'=>$sycp昨日产品数据
 
- 		}
 
- 	    }
 
- 		//time结束
 
- 		
 
- 		
 
- 		//zhcx开始
 
- 		$zhcxdata = array();
 
- 		foreach ($molist as $vval) 
 
- 		{
 
- 			$where = "";
 
- 			$source = $vval;
 
- 			if($source == '2d')
 
- 			{
 
- 				$where = " and source >= '2'";
 
- 			}
 
- 			else if($source != '0')
 
- 			{
 
- 			    $where = " and source = '$source'";
 
- 			}
 
- 		foreach ($zqtime as $value) 
 
- 		{
 
- 			$zdt = $value;
 
- 			$k = $zdt;
 
- 			$tab = 1;
 
- 			
 
- 			//$customer = $this->customer->find_all("shop !=''",'num,zhcx');
 
- 			//$customerkey = array_column($customer,'zhcx'); 
 
-             //$customer= array_combine($customerkey,$customer);
 
- 			//$customersmt = $this->customersmt->find_all("shop !=''",'num,zhcx');
 
- 			//$customersmtkey = array_column($customersmt,'zhcx'); 
 
-             //$customersmt= array_combine($customersmtkey,$customersmt);
 
- 			//$customertt = $this->customertt->find_all("shop !=''",'num,zhcx');
 
- 			//$customerttkey = array_column($customertt,'zhcx'); 
 
-             //$customertt= array_combine($customerttkey,$customertt);
 
- 			if($tab == '1')
 
- 			{
 
- 				if($zdt >= 691200)
 
- 				{
 
- 					$k = $usat-$k-$k;
 
- 			        $j = $usat;
 
- 				    $n = ($j-$k)/(24*3600);
 
- 				}
 
- 				else
 
- 				{
 
- 					$n = 2;
 
- 			        $usat = strtotime(date("Ymd"),time())-$k+2*24*3600;
 
- 				}
 
- 			}
 
- 			else
 
- 			{
 
- 			    $timedata = explode('|',$zdt);
 
- 				$ktime = strtotime($timedata[0]);
 
- 			    $jtime = strtotime($timedata[1]);
 
- 				$ktime = $ktime-($jtime-$ktime);
 
- 				$k = $ktime;
 
- 			    $j = $jtime;
 
- 				$n = ($j-$k)/(24*3600);
 
- 				$usat = $jtime;
 
- 			}
 
- 		    $time=array();$timeold=array();$stime=array();$dlznum = array();$smtnum = array();$ttnum = array();$ymoney = array();$money = array();
 
- 			$dlzmoneyb=array();$smtmoneyb=array();$ttmoneyb=array();$zkh = array();
 
- 			$dlzsl=0;$dlzje=0;$dlzssje=0;$smtsl=0;$smtje=0;$smtssje=0;$ttsl=0;$ttje=0;$ttssje=0;$shopdata = array();
 
- 			$ys = $this->shop->find_all("type != '0' and id != '18' and id != '19' and id != '12' and id != '13' and id != '9' and id != '15' and id != '27' and id != '28' and id != '29' and id != '30' and id != '21' and id != '34'");
 
- 			foreach ($ys as $v) 
 
- 		    {
 
- 				$shopdata[$v['id']] = array('id'=>$v['id'],'b'=>$v['type'],'fdl'=>0,'chl'=>0,'num'=>0,'fgl'=>0);
 
- 				$zkh[$v['id']] = array();
 
- 			}
 
- 		    for($i=1;$i<$n;$i++)
 
- 		    {
 
- 				if($n > 13 && $i > $n/2 || $n < 14)
 
- 				{
 
- 				$t = $usat-($n*24*60*60)+($i*24*60*60);
 
- 			    $time[] = date('m-d',$t);
 
- 				$ct = strtotime(date('Ymd',$t));
 
- 				$ctj = strtotime(date('Ymd',$t+24*3600));
 
- 				$dlz = $this->fullorder->find_all("dtime >= ".$ct." and dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'shop,email');
 
- 				$dlzemail = $this->fullorder->find_all("dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'shop,email');
 
- 				$smt = $this->fullordersmt->find_all("dtime >= ".$ct." and dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'shop,userid');
 
- 				$tt = $this->fullordertt->find_all("state != 217 and dtime >= ".$ct." and dtime <= ".$ctj.$where." and shop != '0' and (".rtrim($fgshop,'or').") and shop != '18' and shop != '19'",'shop,email');
 
- 				//数量及金额结束
 
- 				$sd = array_merge($dlz,$smt,$tt);
 
- 				$fgldata = array();
 
- 				foreach ($sd as $v) 
 
- 		        {
 
- 					/**
 
- 					$array = array(
 
-     0 => array('email' => 123, 'id' => 1),
 
-     1 => array('email' => 321, 'id' => 2),
 
-     2 => array('email' => 123, 'id' => 3),
 
-     3 => array('email' => 123, 'id' => 3)
 
- );
 
- // 使用 array_filter 筛选满足多个条件的元素
 
- $result = array_filter($array, function($item) {
 
-     return $item['email'] === 123 && $item['id'] === 3;
 
- });
 
- // 计算满足条件的数量
 
- $count = count($result);
 
- echo "满足条件 (email = 123 且 id = 3) 的数量是:$count";
 
- **/
 
-                     /** 独立站查customer方法 弃用
 
- 					if(isset($v['email']))
 
- 					{
 
- 					    if(!isset($fgldata[$v['shop'].'-'.$v['email']]))
 
- 					    {
 
- 							$fgldata[$v['shop'].'-'.$v['email']] = 0;
 
- 					    }
 
- 						else
 
- 						{
 
- 							$fgldata[$v['shop'].'-'.$v['email']] += 1;
 
- 						}
 
- 						$zkh[$v['shop']][$v['email']] = array();
 
- 					}
 
- 					**/
 
- 					/** 速卖通
 
- 					else
 
- 					{
 
- 						if(!isset($fgldata[$v['shop'].'-'.$v['userid']]))
 
- 					    {
 
- 							$fgldata[$v['shop'].'-'.$v['userid']] = 0;
 
- 					    }
 
- 						else
 
- 						{
 
- 							$fgldata[$v['shop'].'-'.$v['userid']] += 1;
 
- 						}
 
- 						$zkh[$v['shop']][$v['userid']] = array();
 
- 					}
 
- 					**/
 
- 				}
 
- 				foreach ($sd as $v) 
 
- 		        {
 
- 		            //避免由于作用域引起的问题
 
- 		            $tmp_v = $v;
 
- 					$fdl_result = array_filter($dlz, function($item) use($tmp_v)
 
- 					{
 
- 					    if(!isset($item['email'])||!isset($tmp_v['email'])||!isset($item['shop'])){
 
- 							return false;
 
- 						}else{
 
- 							return $item['email'] === $tmp_v['email'] && $item['shop'] === $tmp_v['email'];
 
- 						}
 
- 						//return $item['email'] === $tmp_v['email'] && $item['shop'] === $tmp_v['email'];
 
- 				    });
 
- 					$fdl = count($fdl_result) > 1?1:0;//返单
 
- 					
 
- 					$chl_result = array_filter($dlz, function($item) use($tmp_v)
 
- 					{
 
- 					    if(!isset($item['email'])||!isset($tmp_v['email'])||!isset($item['shop'])){
 
- 							return false;
 
- 						}else{
 
- 							return $item['email'] === $tmp_v['email'] && $item['shop'] === $tmp_v['email'];
 
- 						}
 
- 						//return $item['email'] === $tmp_v['email'] && $item['shop'] !== $tmp_v['email'];
 
- 				    });
 
- 					$chl = count($chl_result) > 1?1:0;//重合
 
- 					
 
- 					$fgl_result = array_filter($dlzemail, function($item) use($tmp_v)
 
- 					{
 
- 					    if(!isset($item['email'])||!isset($tmp_v['email'])||!isset($item['shop'])){
 
- 							return false;
 
- 						}else{
 
- 							return $item['email'] === $tmp_v['email'] && $item['shop'] === $tmp_v['email'];
 
- 						}
 
- 						//return $item['email'] === $tmp_v['email'] && $item['shop'] === $tmp_v['email'];
 
- 				    });
 
- 					$fgl = count($fgl_result) > 1?1:0;//复购
 
- 					 
 
- 					$shopdata[$v['shop']]['fdl'] = $shopdata[$v['shop']]['fdl']+$fdl;
 
- 					$shopdata[$v['shop']]['chl'] = $shopdata[$v['shop']]['chl']+$chl;
 
- 					$shopdata[$v['shop']]['fgl'] = $shopdata[$v['shop']]['fgl']+$fgl;
 
- 					$shopdata[$v['shop']]['num'] += 1;
 
- 					/**
 
- 					$chl = 0;
 
- 					if(isset($shopdata[$v['shop']]))
 
- 					{
 
- 						if(isset($v['email']))
 
- 						{
 
- 							if(isset($customer[$v['shop'].'-'.$v['email']]['num']))
 
- 							{
 
- 							    $fdl = $customer[$v['shop'].'-'.$v['email']]['num']>1?1:0;
 
- 							}
 
- 							else
 
- 							{
 
- 								$fdl = 0;
 
- 							}
 
- 							foreach ($ys as $vv) 
 
- 		                    {
 
- 				                if($vv['id'] != $v['shop'] && isset($customer[$vv['id'].'-'.$v['email']]))
 
- 								{
 
- 									$chl = 1;
 
- 								}
 
- 			                }
 
- 							if(isset($fgldata[$v['shop'].'-'.$v['email']]))
 
- 							{
 
- 							    $fgl = $fgldata[$v['shop'].'-'.$v['email']]>0?1:0;
 
- 							}
 
- 							else
 
- 							{
 
- 								$fgl = 0;
 
- 							}
 
- 						}
 
- 						else
 
- 						{
 
- 							if(isset($customersmt[$v['shop'].'-'.$v['userid']]['num']))
 
- 							{
 
- 							    $fdl = $customersmt[$v['shop'].'-'.$v['userid']]['num']>1?1:0;
 
- 							}
 
- 							else
 
- 							{
 
- 								$fdl = 0;
 
- 							}
 
- 							foreach ($ys as $vv) 
 
- 		                    {
 
- 				                if($vv['id'] != $v['shop'] && isset($customersmt[$vv['id'].'-'.$v['userid']]))
 
- 								{
 
- 									$chl = 1;
 
- 								}
 
- 			                }
 
- 							if(isset($fgldata[$v['shop'].'-'.$v['userid']]))
 
- 							{
 
- 							    $fgl = $fgldata[$v['shop'].'-'.$v['userid']]>0?1:0;
 
- 							}
 
- 							else
 
- 							{
 
- 								$fgl = 0;
 
- 							}
 
- 						}
 
- 					   
 
- 					}
 
- 					**/
 
-                 }
 
- 				
 
- 				
 
- 				
 
- 				
 
- 				}
 
- 		    }
 
- 			foreach ($shopdata as $k=>$v) 
 
- 		    {
 
- 				$shopdata[$k]['fdl'] = $v['num']=='0'?0:sprintf("%01.2f",($v['fdl']/$v['num']*100)).'%';
 
- 				$shopdata[$k]['chl'] = $v['num']=='0'?0:sprintf("%01.2f",($v['chl']/$v['num']*100)).'%';
 
- 				$shopdata[$k]['fgl'] = count($zkh[$v['id']])=='0'?0:sprintf("%01.2f",($v['fgl']/count($zkh[$v['id']])*100)).'%';
 
- 			}
 
- 			$shopdata = array_values($shopdata);
 
- 			$zhcxdata[$vval][$value] = array('shopdata'=>$shopdata,'success'=>true);
 
- 		}
 
- 		}
 
- 		//zhcx结束
 
- 		$myfile = fopen("./data/tj/".$pdtime.".txt", "w") or die("Unable to open file!");
 
- 		$txt = json_encode(array('zzt'=>$zzt,'tj'=>$zqtdata,'zhcx'=>$zhcxdata));
 
- 		fwrite($myfile, $txt);
 
- 		fclose($myfile);
 
- 		echo 1;
 
- 	}
 
- }
 
 
  |