PinController.class.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 Admin\Controller;
  15. use Admin\Model\PinModel;
  16. class PinController extends CommonController{
  17. protected function _initialize(){
  18. parent::_initialize();
  19. $this->breadcrumb1='订单';
  20. $this->breadcrumb2='拼团管理';
  21. }
  22. public function index(){
  23. $model=new PinModel();
  24. $filter=I('get.');
  25. $state = I('get.state', -1);
  26. //'store_id' => SELLERUID,
  27. $search=array('state' => $state);
  28. $data=$model->show_order_page($search);
  29. $this->state = $state;
  30. $this->assign('empty',$data['empty']);// 赋值数据集
  31. $this->assign('list',$data['list']);// 赋值数据集
  32. $this->assign('page',$data['page']);// 赋值分页输出
  33. $this->display();
  34. }
  35. public function show_order(){
  36. $this->crumbs='拼团详情';
  37. $pin_id = I('get.pin_id');
  38. $pin_info = M('pin')->where( array('pin_id' => $pin_id) )->find();
  39. if($pin_info['state'] == 0 && $pin_info['end_time'] <time()) {
  40. $pin_info['state'] = 2;
  41. }
  42. $this->pin_info = $pin_info;
  43. $sql = "select o.order_num_alias,o.total,o.order_id,o.name,o.telephone,o.shipping_name,o.shipping_tel,o.shipping_city_id,
  44. o.shipping_country_id,o.shipping_province_id,o.shipping_address,o.date_added,o.order_status_id,
  45. og.goods_id,og.name as goods_name,og.goods_images,og.name as goods_name,og.quantity,og.price,og.total as atotal,o.shipping_fare
  46. from ".C('DB_PREFIX')."order as o,".C('DB_PREFIX')."order_goods as og,".C('DB_PREFIX')."pin_order as p
  47. where o.order_id = og.order_id and o.order_id = p.order_id and p.pin_id ={$pin_id}";
  48. $sql.=' ORDER BY o.order_id desc ';
  49. $list = M()->query($sql);
  50. foreach($list as $key => $val)
  51. {
  52. $province_info = M('area')->where( array('area_id' =>$val['shipping_province_id'] ) )->find();
  53. $city_info = M('area')->where( array('area_id' =>$val['shipping_city_id'] ) )->find();
  54. $country_info = M('area')->where( array('area_id' =>$val['shipping_country_id'] ) )->find();
  55. $val['province_name'] = $province_info['area_name'];
  56. $val['city_name'] = $city_info['area_name'];
  57. $val['area_name'] = $country_info['area_name'];
  58. $list[$key] = $val;
  59. }
  60. $pin_buy_sql = "select count(o.order_id) as count from ".C('DB_PREFIX')."pin_order as p,".C('DB_PREFIX')."order as o,".C('DB_PREFIX')."order_goods as og
  61. where p.order_id= o.order_id and p.order_id = og.order_id and p.pin_id = {$pin_id} and o.order_status_id in(1,2,4,6,7,8,9,10)
  62. ";
  63. $pin_buy_count_arr = M()->query($pin_buy_sql);
  64. $pin_buy_count = $pin_buy_count_arr[0]['count'];
  65. $order = current($list);
  66. //$goods_info = M('goods')->where( array('goods_id' => $order['goods_id']) )->find();
  67. $goods_images=resize($order['goods_images'], 50,50);
  68. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  69. $order_id = $hashids->encode($order['order_id']);
  70. $config_info = M('config')->where( array('name' => 'SITE_URL') )->find();
  71. $pin_url = $config_info['value'].'/index.php?s=/group/info/group_order_id/'.$order_id.'.html';
  72. $this->pin_url = $pin_url;
  73. $order_status_list = M('order_status')->select();
  74. $order_status_arr = array();
  75. foreach($order_status_list as $val)
  76. {
  77. $order_status_arr[$val['order_status_id']] = $val['name'];
  78. }
  79. $this->order_status_arr = $order_status_arr;
  80. $this->list = $list;
  81. $this->pin_buy_count = $pin_buy_count;
  82. $this->goods_images = $goods_images;
  83. $this->order = $order;
  84. $this->display('show');
  85. }
  86. }
  87. ?>