You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							171 lines
						
					
					
						
							6.0 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							171 lines
						
					
					
						
							6.0 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								include_once(dirname(dirname(__FILE__))."/library/publicBase.php");
							 | 
						|
								include_once(SERVER_ROOT."/model/mPage.php");
							 | 
						|
								
							 | 
						|
								class index extends publicBase {
							 | 
						|
								
							 | 
						|
								    public function home() {
							 | 
						|
								        $shopinfo = $this->get_shopinfo();
							 | 
						|
								        $uid = $shopinfo['uid'];
							 | 
						|
								        $shop_id = $shopinfo['id'];
							 | 
						|
								
							 | 
						|
								        $obj = new mOrder();
							 | 
						|
								        $this->view['today_data'] = $obj->getTodayData($uid, $shop_id);
							 | 
						|
								        $this->view['total_data'] = $obj->getToalData($uid, $shop_id);
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function ajax_get_data() {
							 | 
						|
								        $shopinfo = $this->get_shopinfo();
							 | 
						|
								        $uid = $shopinfo['uid'];
							 | 
						|
								        $shop_id = $shopinfo['id'];
							 | 
						|
								
							 | 
						|
								        $type = $this->post('type');
							 | 
						|
								        $day = $this->post('day');
							 | 
						|
								
							 | 
						|
								        $obj = new mOrder();
							 | 
						|
								        if ($type == 'sales_volume') {
							 | 
						|
								            $list = $obj->getSumData($uid, $shop_id, $day);
							 | 
						|
								        } elseif ($type == 'refund') {
							 | 
						|
								            $list = $obj->getRefundCountData($uid, $shop_id, $day);
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								        $this->ajax_json(true, 'succ', $list);
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function ajax_get_order_list() {
							 | 
						|
								        $shopinfo = $this->get_shopinfo();
							 | 
						|
								
							 | 
						|
								        $page = $this->get('page')+0;
							 | 
						|
								        $pagesize = $this->get('limit')+0;
							 | 
						|
								
							 | 
						|
								        $obj = new mOrder();
							 | 
						|
								        $list = $obj->getOrderList($shopinfo['uid'], $shopinfo['id'], 0, 0, $page, $pagesize);
							 | 
						|
								        if (empty($list)) $this->ajax_json(false, 'empty list');
							 | 
						|
								
							 | 
						|
								        $goods_ids = array_unique(array_column($list, 'goods_id'));
							 | 
						|
								
							 | 
						|
								        $gobj = new mGoods();
							 | 
						|
								        $goods_list = $gobj->getGoodsByGoodsids($goods_ids);
							 | 
						|
								        if (empty($goods_list)) return true;
							 | 
						|
								
							 | 
						|
								        $goodsid2skuid2info = array();
							 | 
						|
								        foreach ($goods_list as $goods) {
							 | 
						|
								            $goodsid2skuid2info[$goods['goods_id']][$goods['sku_id']] = $goods;
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								        $nlist = array();
							 | 
						|
								        foreach ($list as $info) {
							 | 
						|
								
							 | 
						|
								            $ninfo = array();
							 | 
						|
								            $ninfo['order_sn'] = $info['order_sn'];
							 | 
						|
								            $ninfo['pay_time'] = $info['pay_time'];
							 | 
						|
								            $ninfo['pay_amount'] = $info['pay_amount'];
							 | 
						|
								            $ninfo['order_status_desc'] = $GLOBALS['order_status'][$info['order_status']];
							 | 
						|
								            $ninfo['refund_status_desc'] = $GLOBALS['refund_status'][$info['refund_status']];
							 | 
						|
								            $ninfo['goods_name'] = $goodsid2skuid2info[$info['goods_id']][$info['sku_id']]['goods_name'].' '.$goodsid2skuid2info[$info['goods_id']][$info['sku_id']]['sku_name'];
							 | 
						|
								            $ninfo['goods_id'] = $info['goods_id'];
							 | 
						|
								            $ninfo['sku_id'] = $info['sku_id'];
							 | 
						|
								            $ninfo['is_wait_deliver_goods'] = $info['order_status']==ORDER_STATUS_WAIT_DELIVER_GOODS ? true : false;
							 | 
						|
								            $ninfo['is_refund'] = $info['refund_status']==REFUND_STATUS_NO_AFTER_SALES ? false : true;
							 | 
						|
								            $ninfo['is_refund_succ'] = $info['refund_status']==REFUND_STATUS_SUCC ? true : false;
							 | 
						|
								
							 | 
						|
								            $nlist['data'][] = $ninfo;
							 | 
						|
								        }
							 | 
						|
								
							 | 
						|
								        $nlist['total'] = $obj->getOrdersCount($shopinfo['uid'], $shopinfo['id'])+0;
							 | 
						|
								
							 | 
						|
								        $this->ajax_json(true, 'succ', $nlist);
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function order_list() {
							 | 
						|
								        $url = '/index/order_list';
							 | 
						|
								
							 | 
						|
								        $shopinfo = $this->get_shopinfo();
							 | 
						|
								
							 | 
						|
								        $uid = $shopinfo['uid'];
							 | 
						|
								        $shop_id = $shopinfo['id'];
							 | 
						|
								
							 | 
						|
								        $order_status = $this->get('order_status')+0;
							 | 
						|
								        if ($order_status) $url .= '/order_status/'.$order_status;
							 | 
						|
								
							 | 
						|
								        $refund_status = $this->get('refund_status')+0;
							 | 
						|
								        if ($refund_status) $url .= '/refund_status/'.$refund_status;
							 | 
						|
								
							 | 
						|
								        $obj = new mOrder();
							 | 
						|
								        $count = $obj->getOrdersCount($uid, $shop_id, $order_status, $refund_status);
							 | 
						|
								
							 | 
						|
								        // 分页
							 | 
						|
								        $page = new Page();
							 | 
						|
								        $page->setTotalnum($count);
							 | 
						|
								        $page->setUrl($url.'/page/');
							 | 
						|
								        $curpage = $this->get('page')>0 ? $this->get('page') : 1;
							 | 
						|
								        $page->setPage($curpage);
							 | 
						|
								        $pagesize = $page->pagesize = 50;
							 | 
						|
								        $this->view['page_list'] = $page->getPageList();
							 | 
						|
								        $this->view['curpage'] = $curpage;
							 | 
						|
								
							 | 
						|
								        if ($curpage > 1) $this->view['prev_page'] = $page->url . ($curpage - 1); //上一页连接
							 | 
						|
								        if ($curpage < $page->totalpage) $this->view['post_page'] = $page->url . ($curpage + 1); //下一页连接
							 | 
						|
								
							 | 
						|
								        //只取出当前页显示
							 | 
						|
								        $list = $obj->getOrderList($uid, $shop_id, $order_status, $refund_status, $curpage, $pagesize);
							 | 
						|
								
							 | 
						|
								        $this->view['list'] = $list ? $list : array();
							 | 
						|
								
							 | 
						|
								        $this->view['order_status'] = $GLOBALS['order_status'];
							 | 
						|
								        $this->view['refund_status'] = $GLOBALS['refund_status'];
							 | 
						|
								        if (empty($list)) return true;
							 | 
						|
								
							 | 
						|
								        $goods_ids = array_unique(array_column($list, 'goods_id'));
							 | 
						|
								
							 | 
						|
								        $gobj = new mGoods();
							 | 
						|
								        $goods_list = $gobj->getGoodsByGoodsids($goods_ids);
							 | 
						|
								        if (empty($goods_list)) return true;
							 | 
						|
								
							 | 
						|
								        $goodsid2skuid2info = array();
							 | 
						|
								        foreach ($goods_list as $goods) {
							 | 
						|
								            $goodsid2skuid2info[$goods['goods_id']][$goods['sku_id']] = $goods;
							 | 
						|
								        }
							 | 
						|
								        $this->view['goodsid2skuid2info'] = $goodsid2skuid2info;
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function export_wait_deliver_goods_tids() {
							 | 
						|
								        $shopinfo = $this->get_shopinfo();
							 | 
						|
								        $uid = $shopinfo['uid'];
							 | 
						|
								        $shop_id = $shopinfo['id'];
							 | 
						|
								
							 | 
						|
								        $obj = new mOrder();
							 | 
						|
								
							 | 
						|
								        $filedir = APP_TMEPPATH_WAIT_DELIVER_GOODS_CSV;
							 | 
						|
								        if(!is_dir($filedir)) {
							 | 
						|
								            mkdir($filedir, 0755, true);
							 | 
						|
								            chown($filedir, 'nobody');
							 | 
						|
								            chgrp($filedir, 'nobody');
							 | 
						|
								        }
							 | 
						|
								        $filepath = $filedir."{$uid}_{$shop_id}_".date("YmdHis").".xlsx";
							 | 
						|
								
							 | 
						|
								        ob_get_clean();
							 | 
						|
								        ob_start();
							 | 
						|
								        echo "订单号\t\n";
							 | 
						|
								        echo "order_sn\t\n";
							 | 
						|
								
							 | 
						|
								        for ($page=1;;$page++) {
							 | 
						|
								            $list = $obj->getOrderList($uid, $shop_id, ORDER_STATUS_WAIT_DELIVER_GOODS, REFUND_STATUS_NO_AFTER_SALES, $page, 1000);
							 | 
						|
								            if (empty($list)) break;
							 | 
						|
								
							 | 
						|
								            foreach ($list as $info) {
							 | 
						|
								                echo $info['order_sn']."\t\n";
							 | 
						|
								            }
							 | 
						|
								        }
							 | 
						|
								        header('Content-Disposition: attachment; filename='.$shopinfo['name'].'_待发货订单.xlsx');
							 | 
						|
								        header('Accept-Ranges:bytes');
							 | 
						|
								        header('Content-Length:' . ob_get_length());
							 | 
						|
								        header('Content-Type:application/vnd.ms-excel');
							 | 
						|
								        ob_end_flush();
							 | 
						|
								
							 | 
						|
								        exit();
							 | 
						|
								
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								}
							 | 
						|
								
							 |