diff --git a/control/index.php b/control/index.php index 22dfac8..f5b4504 100644 --- a/control/index.php +++ b/control/index.php @@ -45,48 +45,20 @@ class index extends publicBase { $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; - } - - $GLOBALS['order_status2class'] = array( + $order_status2class = array( ORDER_STATUS_WAIT_DELIVER_GOODS => 'list_status_grey01', ORDER_STATUS_DELIVERED => 'list_status_grey01', ORDER_STATUS_SIGNED_FOR => 'list_status_yellow01', ); - $GLOBALS['refund_status2class'] = array( + $refund_status2class = array( REFUND_STATUS_NO_AFTER_SALES => 'list_status_grey01', REFUND_STATUS_ING => 'list_status_red01', REFUND_STATUS_AFTER_SALE_ING => 'list_status_yellow01', REFUND_STATUS_SUCC => 'list_status_green01', ); - $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['order_status_class'] = $GLOBALS['order_status2class'][$info['order_status']]; - $ninfo['refund_status_class'] = $GLOBALS['refund_status2class'][$info['refund_status']]; - - $nlist['data'][] = $ninfo; - } - + $nlist['data'] = $this->get_nlist($list, $order_status2class, $refund_status2class); $nlist['total'] = $obj->getOrdersCount($shopinfo['uid'], $shopinfo['id'])+0; $this->ajax_json(true, 'succ', $nlist); @@ -104,49 +76,20 @@ class index extends publicBase { $list = $obj->getOrderList($shopinfo['uid'], $shopinfo['id'], 0, REFUND_STATUS_AFTER_SALE_ING, $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; - } - - $GLOBALS['order_status2class'] = array( + $order_status2class = array( ORDER_STATUS_WAIT_DELIVER_GOODS => 'list_status_grey01', ORDER_STATUS_DELIVERED => 'list_status_red01', ORDER_STATUS_SIGNED_FOR => 'list_status_yellow01', ); - $GLOBALS['refund_status2class'] = array( + $refund_status2class = array( REFUND_STATUS_NO_AFTER_SALES => 'list_status_grey01', REFUND_STATUS_ING => 'list_status_red01', REFUND_STATUS_AFTER_SALE_ING => 'list_status_yellow01', REFUND_STATUS_SUCC => 'list_status_green01', ); - $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['after_sales_status_desc'] = $GLOBALS['after_sales_status'][$info['after_sales_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['order_status_class'] = $GLOBALS['order_status2class'][$info['order_status']]; - $ninfo['refund_status_class'] = $GLOBALS['refund_status2class'][$info['refund_status']]; - - $nlist['data'][] = $ninfo; - } - + $nlist['data'] = $this->get_nlist($list, $order_status2class, $refund_status2class); $nlist['total'] = $obj->getOrdersCount($shopinfo['uid'], $shopinfo['id'], 0, REFUND_STATUS_AFTER_SALE_ING)+0; $this->ajax_json(true, 'succ', $nlist); @@ -190,4 +133,78 @@ class index extends publicBase { } + public function wait_deliver_list() {} + + public function ajax_get_wait_deliver_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'], ORDER_STATUS_WAIT_DELIVER_GOODS, REFUND_STATUS_NO_AFTER_SALES, $page, $pagesize); + if (empty($list)) $this->ajax_json(false, 'empty list'); + + $order_status2class = array( + ORDER_STATUS_WAIT_DELIVER_GOODS => 'list_status_grey01', + ORDER_STATUS_DELIVERED => 'list_status_red01', + ORDER_STATUS_SIGNED_FOR => 'list_status_yellow01', + ); + + $refund_status2class = array( + REFUND_STATUS_NO_AFTER_SALES => 'list_status_grey01', + REFUND_STATUS_ING => 'list_status_red01', + REFUND_STATUS_AFTER_SALE_ING => 'list_status_yellow01', + REFUND_STATUS_SUCC => 'list_status_green01', + ); + + $nlist['data'] = $this->get_nlist($list, $order_status2class, $refund_status2class); + $nlist['total'] = $obj->getOrdersCount($shopinfo['uid'], $shopinfo['id'], ORDER_STATUS_WAIT_DELIVER_GOODS, REFUND_STATUS_NO_AFTER_SALES)+0; + + $this->ajax_json(true, 'succ', $nlist); + } + + private function get_nlist($list, $order_status2class, $refund_status2class) { + $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['after_sales_status_desc'] = $GLOBALS['after_sales_status'][$info['after_sales_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['order_status_class'] = $order_status2class[$info['order_status']]; + $ninfo['refund_status_class'] = $refund_status2class[$info['refund_status']]; + $ninfo['urge_shipping_time'] = $info['urge_shipping_time']; + $ninfo['is_urge'] = $info['urge_shipping_time'] == '0000-00-00 00:00:00' ? false : true; + + $ninfo['is_show_count_down'] = $is_show_count_down = strtotime($info['last_ship_time'])-time()>0 ? true : false; + if ($is_show_count_down) { + $count_down = $gobj->getHourMinuteSecondCountDown($info['last_ship_time'], date("Y-m-d H:i:s")); + $count_down_str = $count_down['hour'].':'.$count_down['minute'].':'.$count_down['second']; + } + $ninfo['count_down'] = $is_show_count_down ? $count_down_str : 0; + + $nlist[] = $ninfo; + } + + return $nlist; + } + } diff --git a/model/mBase.php b/model/mBase.php index fac5eb4..5a0c312 100644 --- a/model/mBase.php +++ b/model/mBase.php @@ -1423,6 +1423,11 @@ class mBase extends publicBase { return shell_exec($cmd); } + /** + * 获取周的开始日期和结束日期 + * @param unknown $default_date + * @return string[] + */ public function getWeekStartEndDate($default_date) { //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期 $first=1; @@ -1439,4 +1444,22 @@ class mBase extends publicBase { ); } + /** + * 获取时分秒倒计时 + * @param unknown $start_time + * @param unknown $end_time + * @return array|number[]|mixed[] + */ + public function getHourMinuteSecondCountDown($start_time, $end_time) { + $count_down = strtotime($end_time) - strtotime($start_time); + if ($count_down <= 0) return array(); + + $data = array(); + $data['hour'] = $h = floor($count_down/3600); + $data['minute'] = $m = floor(($count_down - $h*3600)/60); + $data['second'] = $count_down - $h*3600 - $m*60; + + return $data; + } + } diff --git a/view/templates/index/after_sale_list.html b/view/templates/index/after_sale_list.html index 703ae30..7442c7f 100644 --- a/view/templates/index/after_sale_list.html +++ b/view/templates/index/after_sale_list.html @@ -30,7 +30,7 @@