store.inc.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <?php
  2. global $_GPC, $_W;
  3. $GLOBALS['frames'] = $this->getMainMenu();
  4. $where=" where a.uniacid=:uniacid";
  5. $data[':uniacid']=$_W['uniacid'];
  6. $type=isset($_GPC['type'])?$_GPC['type']:'wait';
  7. $tztype=pdo_getall('zhtc_storetype',array('uniacid'=>$_W['uniacid']));
  8. $state=$_GPC['state'];
  9. if($type=='wait'){
  10. $state=1;
  11. }
  12. if(isset($_GPC['keywords'])){
  13. $where.=" and (a.store_name LIKE concat('%', :name,'%') || a.tel LIKE concat('%', :name,'%')) ";
  14. $data[':name']=$_GPC['keywords'];
  15. $type='all';
  16. }else{
  17. if($state){
  18. $where.=" and a.state=:state ";
  19. $data[':state']=$state;
  20. }
  21. }
  22. if($_GPC['type_id']>0){
  23. $where.=" and a.storetype_id=".$_GPC['type_id'];
  24. }
  25. $pageindex = max(1, intval($_GPC['page']));
  26. $pagesize=10;
  27. $sql="SELECT a.*,b.type as typename,c.type_name FROM ".tablename('zhtc_store'). " a" . " left join " . tablename("zhtc_in") . " b on b.id=a.type left join " . tablename("zhtc_storetype") . " c on c.id=a.storetype_id".$where." ORDER BY a.id DESC";
  28. $total=pdo_fetchcolumn("select count(*) from " .tablename('zhtc_store'). " a" . " left join " . tablename("zhtc_in") . " b on b.id=a.type left join " . tablename("zhtc_storetype") . " c on c.id=a.storetype_id".$where,$data);
  29. //echo $sql;die;
  30. $select_sql =$sql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize;
  31. $list=pdo_fetchall($select_sql,$data);
  32. $pager = pagination($total, $pageindex, $pagesize);
  33. if($_GPC['op']=='delete'){
  34. $res=pdo_delete('zhtc_store',array('id'=>$_GPC['id']));
  35. if($res){
  36. message('删除成功!', $this->createWebUrl('store'), 'success');
  37. }else{
  38. message('删除失败!','','error');
  39. }
  40. }
  41. if($_GPC['op']=='tg'){
  42. $rst=pdo_get('zhtc_store',array('id'=>$_GPC['id']));
  43. if(!$rst['sh_time']){//增加
  44. if($rst['type']==1){
  45. $time=24*60*60*7;
  46. }
  47. if($rst['type']==2){
  48. $time=24*182*60*60;
  49. }
  50. if($rst['type']==3){
  51. $time=24*365*60*60;
  52. }
  53. $time2=time();
  54. $res=pdo_update('zhtc_store',array('state'=>2,'sh_time'=>$time2,'dq_time'=>time()+$time),array('id'=>$_GPC['id']));
  55. }else{//修改
  56. $res=pdo_update('zhtc_store',array('state'=>2),array('id'=>$_GPC['id']));
  57. }
  58. if($res){
  59. message('通过成功!', $this->createWebUrl('store'), 'success');
  60. }else{
  61. message('通过失败!','','error');
  62. }
  63. }
  64. if($_GPC['op']=='jj'){
  65. $res=pdo_update('zhtc_store',array('state'=>3,'sh_time'=>time()),array('id'=>$_GPC['id']));
  66. if($res){
  67. message('拒绝成功!', $this->createWebUrl('store'), 'success');
  68. }else{
  69. message('拒绝失败!','','error');
  70. }
  71. }
  72. if(checksubmit('submit2')){
  73. $res=pdo_update('zhtc_store',array('wallet +='=>$_GPC['reply']),array('id'=>$_GPC['id2']));
  74. if($res){
  75. $data2['money']=$_GPC['reply'];
  76. if($data2['money']>0){
  77. $data2['store_id']=$_GPC['id2'];
  78. $data2['type']=1;
  79. $data2['note']='后台充值';
  80. $data2['time']=date('Y-m-d H:i:s');
  81. }elseif($data2['money']<0){
  82. $data2['store_id']=$_GPC['id2'];
  83. $data2['type']=2;
  84. $data2['note']='后台扣费';
  85. $data2['time']=date('Y-m-d H:i:s');
  86. }
  87. $res2=pdo_insert('zhtc_store_wallet',$data2);
  88. if($res2){
  89. message('充值成功!', $this->createWebUrl('store'), 'success');
  90. }else{
  91. message('充值失败!','','error');
  92. }
  93. }
  94. }
  95. if($_GPC['op']=='ql'){
  96. $res=pdo_get('zhtc_store',array('id'=>$_GPC['id']));
  97. $res2=pdo_update('zhtc_store',array('wallet -='=>$res['wallet']),array('id'=>$_GPC['id']));
  98. if($res){
  99. $data2['money']=$res['wallet'];
  100. $data2['store_id']=$_GPC['id'];
  101. $data2['type']=2;
  102. $data2['note']='后台扣费';
  103. $data2['time']=date('Y-m-d H:i:s');
  104. $res2=pdo_insert('zhtc_store_wallet',$data2);
  105. if($res2){
  106. message('操作成功!', $this->createWebUrl('store'), 'success');
  107. }else{
  108. message('操作失败!','','error');
  109. }
  110. }
  111. }
  112. if(checksubmit('export_submit', true)) {
  113. $time=date("Y-m-d");
  114. $time="'%$time%'";
  115. $start=$_GPC['time']['start'];
  116. $end=$_GPC['time']['end'];
  117. $count = pdo_fetchcolumn("SELECT COUNT(*) FROM". tablename("zhtc_store")." WHERE uniacid={$_W['uniacid']}");
  118. $pagesize = ceil($count/5000);
  119. //array_unshift( $names, '活动名称');
  120. $header = array(
  121. 'id'=>'商家id',
  122. 'store_name' => '商家名称',
  123. 'tel' => '商家电话',
  124. 'address' => '商家地址',
  125. 'coordinates' => '坐标地址',
  126. 'logo' => '商家logo',
  127. 'weixin_logo' => '老板微信logo',
  128. 'ad' => '商家轮播图',
  129. 'announcement' => '公告',
  130. 'start_time' => '营业开始时间',
  131. 'end_time' => '营业结束时间',
  132. 'views' => '人气',
  133. 'facilities' => '店内设施',
  134. 'cityname' => '所属城市',
  135. 'details' => '商家简介',
  136. 'type_name' => '行业分类',
  137. 'nTypeName' => '二级栏目分类',
  138. 'is_top' => '是否置顶',
  139. 'is_rm' => '品质商家',
  140. 'state' => '状态'
  141. );
  142. $keys = array_keys($header);
  143. $html = "\xEF\xBB\xBF";
  144. foreach ($header as $li) {
  145. $html .= $li . "\t ,";
  146. }
  147. $html .= "\n";
  148. for ($j = 1; $j <= $pagesize; $j++) {
  149. $sql = "select a.*,b.type_name,c.name as nTypeName from " . tablename("zhtc_store")." a" . " left join " . tablename("zhtc_storetype")." b on a.storetype_id=b.id left join " . tablename("zhtc_storetype2")." c on a.storetype2_id=c.id WHERE a.uniacid={$_W['uniacid']} limit " . ($j - 1) * 5000 . ",5000 ";
  150. $list = pdo_fetchall($sql);
  151. }
  152. if (!empty($list)) {
  153. $size = ceil(count($list) / 500);
  154. for ($i = 0; $i < $size; $i++) {
  155. $buffer = array_slice($list, $i * 500, 500);
  156. $user = array();
  157. foreach ($buffer as $k =>$row) {
  158. $row['coordinates']=str_replace(',','#',$row['coordinates']);
  159. $row['address']=str_replace(',',',',$row['address']);
  160. $row['address']=str_replace(array("/r/n", "/r", "/n"), $row['address']);
  161. $row['details']=str_replace(',',',',$row['details']);
  162. $row['details']=str_replace(array("/r/n", "/r", "/n"), $row['details']);
  163. $row['announcement']=str_replace(',',',',$row['announcement']);
  164. $row['announcement']=str_replace(array("/r/n", "/r", "/n"), $row['announcement']);
  165. $row['store_name']=str_replace(',',',',$row['store_name']);
  166. $row['store_name']=str_replace(array("/r/n", "/r", "/n"), $row['store_name']);
  167. $row['ad']=str_replace(',','#',$row['ad']);
  168. if($row['state']==1){
  169. $row['state']='待审核';
  170. }elseif($row['state']==2){
  171. $row['state']='已通过';
  172. }elseif($row['state']==3){
  173. $row['state']='已拒绝';
  174. }elseif($row['state']==4){
  175. $row['state']='已过期';
  176. }
  177. if($row['is_top']==1){
  178. $row['is_top']='是';
  179. }elseif($row['is_top']==2){
  180. $row['is_top']='否';
  181. }
  182. if($row['is_rm']==1){
  183. $row['is_rm']='是';
  184. }elseif($row['is_rm']==2){
  185. $row['is_rm']='否';
  186. }
  187. $row['cityname']=$row['cityname']?:'全国';
  188. $row['facilities']='';
  189. if($row['skzf']==1){
  190. $row['facilities'] .="#刷卡支付";
  191. }
  192. if($row['wifi']==1){
  193. $row['facilities'] .="#WIFI";
  194. }
  195. if($row['mftc']==1){
  196. $row['facilities'] .="#免费停车";
  197. }
  198. if($row['jzxy']==1){
  199. $row['facilities'] .="#禁止吸烟";
  200. }
  201. if($row['tgbj']==1){
  202. $row['facilities'] .="#提供包间";
  203. }
  204. if($row['sfxx']==1){
  205. $row['facilities'] .="#沙发休闲";
  206. }
  207. foreach ($keys as $key) {
  208. $data5[] = $row[$key];
  209. }
  210. $user[] = implode("\t ,", $data5) . "\t ,";
  211. unset($data5);
  212. }
  213. $html .= implode("\n", $user) . "\n";
  214. }
  215. }
  216. header("Content-type:text/csv");
  217. header("Content-Disposition:attachment; filename=商家数据.csv");
  218. echo $html;
  219. exit();
  220. }
  221. include $this->template('web/store');