index.inc.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. global $_GPC, $_W;
  3. $GLOBALS['frames'] = $this->getMainMenu();
  4. $system=pdo_get('zhtc_system',array('uniacid'=>$_W['uniacid']));
  5. $time=time()-$system['sh_time']*24*60*60;
  6. if($system['sh_time']>0){
  7. $res=pdo_getall('zhtc_order',array('state'=>3,'fh_time <='=>$time,'uniacid'=>$_W['uniacid']));
  8. for($i=0;$i<count($res);$i++){
  9. pdo_update('zhtc_order',array('state'=>4,'complete_time'=>time()),array('id'=>$res[$i]['id']));
  10. pdo_update('zhtc_store',array('wallet +='=>$res[$i]['money']),array('id'=>$res[$i]['store_id']));
  11. $data['store_id']=$res[$i]['store_id'];
  12. $data['money']=$res[$i]['money'];
  13. $data['note']='商品订单';
  14. $data['type']=1;
  15. $data['time']=date("Y-m-d H:i:s");
  16. pdo_insert('zhtc_store_wallet',$data);
  17. if($system['good_jf']>0){
  18. pdo_update('zhtc_user',array('total_score +='=>$system['good_jf']),array('id'=>$res[$i]['user_id']));
  19. $data2['score']=$system['good_jf'];
  20. $data2['user_id']=$res[$i]['user_id'];
  21. $data2['tid']=$res[$i]['id'];
  22. $data2['note']='商品订单';
  23. $data2['type']=1;
  24. $data2['cerated_time']=date('Y-m-d H:i:s');
  25. $data2['uniacid']=$_W['uniacid'];//小程序id
  26. pdo_insert('zhtc_integral',$data2);//添加积分明细
  27. }
  28. }
  29. }
  30. $fx=pdo_getall('zhtc_distribution',array('pay_state'=>2,'state'=>2,'is_log'=>1));
  31. for($j=0;$j<count($fx);$j++){
  32. $data2['user_id']=$fx[$j]['user_id'];
  33. $data2['money']=$fx[$j]['money'];
  34. $data2['time']=date("Y-m-d H:i:s",$fx[$j]['time']);
  35. $data2['level']=$fx[$j]['level'];
  36. $data2['state']=2;
  37. $data2['note']='申请合伙人';
  38. pdo_insert('zhtc_fxlog',$data2);
  39. pdo_update('zhtc_distribution',array('is_log'=>2),array('id'=>$fx[$j]['id']));
  40. }
  41. //会员信息
  42. $time=date("Y-m-d");
  43. $time2=date("Y-m-d",strtotime("-1 day"));
  44. $time3=date("Y-m");
  45. //会员总数
  46. $totalhy=pdo_get('zhtc_user', array('uniacid'=>$_W['uniacid']), array('count(id) as count'));
  47. //今日新增会员
  48. $sql=" select a.* from (select id,FROM_UNIXTIME(time) as time from".tablename('zhtc_user')." where uniacid={$_W['uniacid']}) a where time like '%{$time}%' ";
  49. $jir=count(pdo_fetchall($sql));
  50. //昨日新增
  51. $sql2=" select a.* from (select id,FROM_UNIXTIME(time) as time from".tablename('zhtc_user')." where uniacid={$_W['uniacid']}) a where time like '%{$time2}%' ";
  52. $zuor=count(pdo_fetchall($sql2));
  53. //本月新增
  54. $sql3=" select a.* from (select id,FROM_UNIXTIME(time) as time from".tablename('zhtc_user')." where uniacid={$_W['uniacid']}) a where time like '%{$time3}%' ";
  55. $beny=count(pdo_fetchall($sql3));
  56. //商品一览
  57. //商品总数
  58. $goodstotal=pdo_get('zhtc_goods', array('uniacid'=>$_W['uniacid'],'state'=>2), array('count(id) as count'));
  59. //新增商品
  60. $sql4=" select a.* from (select id,FROM_UNIXTIME(time) as time from".tablename('zhtc_goods')." where uniacid={$_W['uniacid']}) a where time like '%{$time}%' ";
  61. $jrgoods=count(pdo_fetchall($sql4));
  62. //总共订单
  63. $totalorder=pdo_get('zhtc_order', array('uniacid'=>$_W['uniacid']), array('count(id) as count'));
  64. //代发货订单
  65. $dfhorder=pdo_get('zhtc_order', array('uniacid'=>$_W['uniacid'],'state'=>2), array('count(id) as count'));
  66. //帖子数量
  67. $tztotal=pdo_get('zhtc_information', array('uniacid'=>$_W['uniacid'],'state'=>2), array('count(id) as count'));
  68. //商户数量
  69. $shtotal=pdo_get('zhtc_store', array('uniacid'=>$_W['uniacid'],'state'=>2), array('count(id) as count'));
  70. //拼车数量
  71. $pctotal=pdo_get('zhtc_car', array('uniacid'=>$_W['uniacid'],'state'=>2), array('count(id) as count'));
  72. //黄页数量
  73. $hytotal=pdo_get('zhtc_yellowstore', array('uniacid'=>$_W['uniacid'],'state'=>2), array('count(id) as count'));
  74. //资讯数量
  75. $zxtotal=pdo_get('zhtc_zx', array('uniacid'=>$_W['uniacid'],'state'=>2), array('count(id) as count'));
  76. //数据概况
  77. //今日新增帖子
  78. $sql5=" select a.* from (select id,hb_money,hb_num,hb_type,hb_random,FROM_UNIXTIME(sh_time) as time,uniacid from".tablename('zhtc_information')." where uniacid={$_W['uniacid']} and state=2) a where time like '%{$time}%' and uniacid={$_W['uniacid']} ";
  79. $tzinfo=pdo_fetchall($sql5);
  80. $jrtz=count($tzinfo);
  81. //今日新增商户
  82. $sql6=" select a.* from (select id,FROM_UNIXTIME(sh_time) as time from".tablename('zhtc_store')." where uniacid={$_W['uniacid']} and state=2) a where time like '%{$time}%' ";
  83. $jrsh=count(pdo_fetchall($sql6));
  84. //获取今日红包金额
  85. $jrhb=0;
  86. if($tzinfo){
  87. foreach($tzinfo as $v){
  88. if($v['hb_random']==1){
  89. $jrhb+=$v['hb_money'];
  90. }
  91. if($v['hb_random']==2){
  92. $jrhb+=$v['hb_money']*$v['hb_num'];
  93. }
  94. }
  95. }
  96. $jrtmoney=0;
  97. //今日销售金额
  98. //今日订单销售金额
  99. $sql7=" select sum(a.money) as ordermoney from (select id,money,FROM_UNIXTIME(time) as time from".tablename('zhtc_order')." where uniacid={$_W['uniacid']} and state in (2,3,4,5,7)) a where time like '%{$time}%' ";
  100. $ordermoney=pdo_fetch($sql7);
  101. //商家入驻的钱
  102. $sql8=" select sum(money) as storemoney from".tablename('zhtc_storepaylog')." where uniacid={$_W['uniacid']} and time like '%{$time}%' ";
  103. $storemoney=pdo_fetch($sql8);
  104. //帖子入驻加置顶
  105. $sql9=" select sum(money) as tzmoney from".tablename('zhtc_tzpaylog')." where uniacid={$_W['uniacid']} and time like '%{$time}%' ";
  106. $tzmoney=pdo_fetch($sql9);
  107. //拼车发布的钱
  108. $sql10=" select sum(money) as pcmoney from".tablename('zhtc_carpaylog')." where uniacid={$_W['uniacid']} and time like '%{$time}%' ";
  109. $pcmoney=pdo_fetch($sql10);
  110. //114入驻的钱
  111. $sql11=" select sum(money) as hymoney from".tablename('zhtc_yellowpaylog')." where uniacid={$_W['uniacid']} and time like '%{$time}%' ";
  112. $hymoney=pdo_fetch($sql11);
  113. //合伙人的钱
  114. // $zttime=strtotime(date("Y-m-d",strtotime("+1 day")));
  115. // $jttime=strtotime(date("Y-m-d"));
  116. // $sql12=" select sum(money) as hhrmoney from".tablename('zhtc_distribution')." where uniacid={$_W['uniacid']} and time < ".$zttime." and pay_state=2 and time >= ".$jttime;
  117. // $hhrmoney=pdo_fetch($sql12);
  118. $where=" and a.time like '%{$time}%'";
  119. $zttime=strtotime(date("Y-m-d",strtotime("+1 day")));
  120. $jttime=strtotime(date("Y-m-d"));
  121. $sql12=" select sum(a.money) as hhrmoney from".tablename('zhtc_fxlog')." a" . " left join " . tablename("zhtc_user") . " b on b.id=a.user_id where b.uniacid={$_W['uniacid']} and a.state=2".$where;
  122. $hhrmoney=pdo_fetch($sql12);
  123. //今日总金额
  124. $jrtmoney=$ordermoney['ordermoney']+$storemoney['storemoney']+$tzmoney['tzmoney']+$pcmoney['pcmoney']+$hymoney['hymoney']+$hhrmoney['hhrmoney'];
  125. include $this->template('web/index');