dlgoodrank.inc.php
1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
global $_GPC, $_W;
$action = 'start';
$uid=$_COOKIE["uid"];
$storeid=$_COOKIE["storeid"];
$cur_store = $this->getStoreById($storeid);
$GLOBALS['frames'] = $this->getNaveMenu($storeid, $action,$uid);
$type=$_GPC['type']?$_GPC['type']:'wm';
if($type=='wm'){
$goods=pdo_getall('cjdc_goods',array('store_id'=>$storeid,'type'=>array(1,3)),array('id'));
$where=' and b.state in (4,5,10)';
}else{
$goods=pdo_getall('cjdc_goods',array('store_id'=>$storeid,'type'=>array(2,3)),array('id'));
$where=' and b.dn_state=2';
}
$goods=array_column($goods,'id');
$data=array();
for($i=0;$i<count($goods);$i++){
$sql = "select sum(a.number) as goodnum ,a.name,a.img from " . tablename("cjdc_order_goods") . " a" . " left join " . tablename("cjdc_order") . " b on b.id=a.order_id where a.dishes_id={$goods[$i]} ".$where;
$number=pdo_fetch($sql);
$number['goodnum']=$number['goodnum']?$number['goodnum']:0;
if($number['goodnum']>0){
$data[]=array(
'id'=>$goods[$i],
'goodnum'=>$number['goodnum'],
'name'=>$number['name'],
'img'=>$number['img']
);
}
}
foreach ($data as $key => $row)
{
$goodnum[$key] = $row['goodnum'];
}
array_multisort($goodnum, SORT_DESC, $data);
include $this->template('web/dlgoodrank');