PinModel.class.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Model;
  15. class PinModel{
  16. /**
  17. *显示订单状态单位分页
  18. */
  19. public function show_order_page($search){
  20. $sql = "select p.pin_id,p.is_jiqi,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['name']) && !empty($search['name']) ){
  27. $sql.=" and og.name like '%".$search['name']."%'";
  28. }
  29. if(isset($search['state'])){
  30. if($search['state'] == -1)
  31. {
  32. } else if($search['state'] == 0) {
  33. $sql.=" and p.state=0 and p.end_time > ".time();
  34. } else if($search['state'] == 1) {
  35. $sql.=" and p.state=1";
  36. } else if($search['state'] == 2) {
  37. $sql.=" and (p.state=2 or (p.state = 0 and p.end_time <".time()." ) )";
  38. }
  39. }
  40. $count=count(M()->query($sql));
  41. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  42. $show = $Page->show();// 分页显示输出
  43. $sql.=' ORDER BY p.pin_id desc LIMIT '.$Page->firstRow.','.$Page->listRows;
  44. $list=M()->query($sql);
  45. foreach($list as $key => $val)
  46. {
  47. $sql = "select count(o.order_id) as count from ".C('DB_PREFIX')."pin_order as po,".C('DB_PREFIX')."order as o
  48. 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) ";
  49. $count_arr = M()->query($sql);
  50. $pin_buy_count = $count_arr[0]['count'];
  51. $pin_jia_count = M('jiapinorder')->where( array('pin_id' => $val['pin_id']) )->count();
  52. if($val['state'] == 0 && $val['end_time'] <time()) {
  53. $val['state'] = 2;
  54. }
  55. $val['buy_count'] = $pin_buy_count + $pin_jia_count;
  56. $list[$key] = $val;
  57. }
  58. return array(
  59. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  60. 'list'=>$list,
  61. 'page'=>$show
  62. );
  63. }
  64. public function pin_info()
  65. {
  66. }
  67. }
  68. ?>