PinModel.class.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Admin\Model;
  15. class PinModel{
  16. /**
  17. *显示订单状态单位分页
  18. */
  19. public function show_order_page($search){
  20. $sql = "select p.pin_id,og.goods_id,og.name,p.state,p.need_count,p.end_time,p.begin_time from ".C('DB_PREFIX')."pin as p,".C('DB_PREFIX')."pin_order as o,".C('DB_PREFIX')."order_goods as og
  21. where p.order_id= o.order_id and p.order_id = og.order_id
  22. ";
  23. if(isset($search['store_id'])){
  24. $sql.=" and og.store_id=".$search['store_id'];
  25. }
  26. if(isset($search['state'])){
  27. if($search['state'] == -1)
  28. {
  29. } else if($search['state'] == 0) {
  30. $sql.=" and p.state=0 and p.end_time > ".time();
  31. } else if($search['state'] == 1) {
  32. $sql.=" and p.state=1";
  33. } else if($search['state'] == 2) {
  34. $sql.=" and (p.state=2 or (p.state = 0 and p.end_time <".time()." ) )";
  35. }
  36. }
  37. $count=count(M()->query($sql));
  38. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  39. $show = $Page->show();// 分页显示输出
  40. $sql.=' ORDER BY p.pin_id desc LIMIT '.$Page->firstRow.','.$Page->listRows;
  41. $list=M()->query($sql);
  42. foreach($list as $key => $val)
  43. {
  44. $sql = "select count(o.order_id) as count from ".C('DB_PREFIX')."pin_order as po,".C('DB_PREFIX')."order as o
  45. where po.order_id= o.order_id and po.pin_id = ".$val['pin_id']." and o.order_status_id in(1,2,4,6,7,8,9,10) ";
  46. $count_arr = M()->query($sql);
  47. $pin_buy_count = $count_arr[0]['count'];
  48. if($val['state'] == 0 && $val['end_time'] <time()) {
  49. $val['state'] = 2;
  50. }
  51. $val['buy_count'] = $pin_buy_count;
  52. $list[$key] = $val;
  53. }
  54. return array(
  55. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  56. 'list'=>$list,
  57. 'page'=>$show
  58. );
  59. }
  60. public function pin_info()
  61. {
  62. }
  63. }
  64. ?>