sjstatistics.inc.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. global $_GPC, $_W;
  3. if($_GPC['account_id']){
  4. $role=pdo_get('zhtc_account',array('uid'=>$_GPC['account_id'],'weid'=>$_W['uniacid']));
  5. setcookie('storeid',$role['storeid']);
  6. $storeid=$role['storeid'];
  7. }else{
  8. $storeid=$_COOKIE["storeid"];
  9. }
  10. $cur_store = $this->getStoreById($storeid);
  11. $store=pdo_get('zhtc_store',array('id'=>$storeid,'uniacid'=>$_W['uniacid']),array('wallet','dq_time','views'));
  12. $GLOBALS['frames'] = $this->getNaveMenu2($storeid);
  13. $time = date("Y-m-d");
  14. $time = "'%$time%'";
  15. $zttime=date("Y-m-d",strtotime("-1 day"));
  16. $zttime = "'%$zttime%'";
  17. function Profit($storeid,$time){
  18. if($time){
  19. $where=" FROM_UNIXTIME(complete_time) LIKE " . $time . " and ";
  20. $where2=" time LIKE " . $time . " and";
  21. $where3=" a.time LIKE " . $time . " and";
  22. $where4=" pay_time LIKE " . $time . " and";
  23. }
  24. $dd = "select sum(money) as total from " . tablename("zhtc_order") . " WHERE ".$where." store_id=" . $storeid . " and state in (4,7)";
  25. $dd = pdo_fetch($dd); //今天的订单销售额
  26. $dd=empty($dd['total'])?'0.00':$dd['total'];
  27. $dmf = "select sum(money) as total from " . tablename("zhtc_dmorder") . " WHERE ".$where2." store_id=" . $storeid . " and state=2";
  28. $dmf = pdo_fetch($dmf); //今天的当面付销售额
  29. $dmf=empty($dmf['total'])?'0.00':$dmf['total'];
  30. $yhq = "select sum(a.lq_money) as total from " . tablename("zhtc_usercoupons") . " a" . " left join " . tablename("zhtc_coupons") . " b on b.id=a.coupons_id WHERE ".$where3." b.store_id=" . $storeid . " and a.pay_type=2";
  31. $yhq = pdo_fetch($yhq); //今天的优惠券销售额
  32. $yhq=empty($yhq['total'])?'0.00':$yhq['total'];
  33. $qg = "select sum(money) as total from " . tablename("zhtc_qgorder") ." WHERE ".$where4." store_id=" . $storeid . " and state in (2,3)";
  34. $qg = pdo_fetch($qg); //今天的抢购销售额
  35. $qg=empty($qg['total'])?'0.00':$qg['total'];
  36. $pt= "select sum(money) as total from " . tablename("zhtc_store_wallet") ." WHERE ".$where2." note='拼团订单' and store_id=" . $storeid;
  37. $pt = pdo_fetch($pt);
  38. $pt=empty($pt['total'])?'0.00':$pt['total'];
  39. $total = $dd + $dmf + $yhq + $qg+$pt; //今天的销售额
  40. return $total;
  41. }
  42. $data['jt']=Profit($storeid,$time);
  43. $data['zt']=Profit($storeid,$zttime);
  44. $data['all']=Profit($storeid,'');
  45. //今日订单
  46. $sql="select count(id) as total from " . tablename("zhtc_order") . " WHERE store_id=:store_id and del2=2 and FROM_UNIXTIME(time) LIKE " . $time ;
  47. $order=pdo_fetch($sql,array(':store_id'=>$storeid));
  48. //订单统计
  49. $sql2="select count(case when state=2 then 1 end) as dfh,count( case when state=1 then 1 end) as dfk, count( case when state=4 then 1 end) as ywc, count( case when state=5 then 1 end) as dtk from ".tablename('zhtc_order')." where uniacid=:uniacid and store_id=:store_id and del2=2";
  50. $count=pdo_fetch($sql2,array('uniacid'=>$_W['uniacid'],':store_id'=>$storeid));
  51. include $this->template('web/sjstatistics');