PinorderController.class.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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\Controller;
  15. use Seller\Model\PinModel;
  16. class PinorderController 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. $search=array('state' => $state,'store_id' => SELLERUID);
  27. $data=$model->show_order_page($search);
  28. $this->state = $state;
  29. $this->assign('empty',$data['empty']);// 赋值数据集
  30. $this->assign('list',$data['list']);// 赋值数据集
  31. $this->assign('page',$data['page']);// 赋值分页输出
  32. $this->display();
  33. }
  34. public function show_order(){
  35. $this->crumbs='拼团详情';
  36. $pin_id = I('get.pin_id');
  37. $pin_info = M('pin')->where( array('pin_id' => $pin_id) )->find();
  38. if($pin_info['state'] == 0 && $pin_info['end_time'] <time()) {
  39. $pin_info['state'] = 2;
  40. }
  41. $this->pin_info = $pin_info;
  42. $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,
  43. o.shipping_country_id,o.shipping_province_id,o.shipping_address,o.date_added,o.order_status_id,og.goods_id
  44. from ".C('DB_PREFIX')."order as o,".C('DB_PREFIX')."order_goods as og
  45. where o.order_id = og.order_id and o.pin_id ={$pin_id}";
  46. $sql.=' ORDER BY o.order_id desc ';
  47. $list = M()->query($sql);
  48. foreach($list as $key => $val)
  49. {
  50. $province_info = M('area')->where( array('area_id' =>$val['shipping_province_id'] ) )->find();
  51. $city_info = M('area')->where( array('area_id' =>$val['shipping_city_id'] ) )->find();
  52. $country_info = M('area')->where( array('area_id' =>$val['shipping_country_id'] ) )->find();
  53. $val['province_name'] = $province_info['area_name'];
  54. $val['city_name'] = $city_info['area_name'];
  55. $val['area_name'] = $country_info['area_name'];
  56. $list[$key] = $val;
  57. }
  58. $pin_buy_count = M('order')->where("pin_id={$pin_id} and order_status_id in(1,2,4,6,7,8,9,10)")->count();
  59. $order = current($list);
  60. $goods_info = M('goods')->where( array('goods_id' => $order['goods_id']) )->find();
  61. $goods_info['image']=resize($goods_info['image'], 40,40);
  62. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  63. $order_id = $hashids->encode($order['order_id']);
  64. $config_info = M('config')->where( array('name' => 'SITE_URL') )->find();
  65. $pin_url = $config_info['value'].'/index.php?s=/group/info/group_order_id/'.$order_id.'.html';
  66. $this->pin_url = $pin_url;
  67. $order_status_list = M('order_status')->select();
  68. $order_status_arr = array();
  69. foreach($order_status_list as $val)
  70. {
  71. $order_status_arr[$val['order_status_id']] = $val['name'];
  72. }
  73. $this->order_status_arr = $order_status_arr;
  74. $this->list = $list;
  75. $this->pin_buy_count = $pin_buy_count;
  76. $this->goods_info = $goods_info;
  77. $this->display('show');
  78. }
  79. }
  80. ?>