From bd84cdea8b8dec8ddb0a30fc7c2f5d7cf43c3c89 Mon Sep 17 00:00:00 2001 From: xxb Date: Tue, 3 Aug 2021 10:22:33 +0800 Subject: [PATCH] liche update for admin order purchase manger --- admin/controllers/app/liche/Main.php | 12 ++ admin/controllers/order/Purchase.php | 143 ++++++++++++++++ admin/views/order/purchase/lists.php | 187 +++++++++++++++++++++ common/services/apporder/Order_service.php | 133 +++++++++++++++ 4 files changed, 475 insertions(+) create mode 100644 admin/controllers/order/Purchase.php create mode 100644 admin/views/order/purchase/lists.php create mode 100644 common/services/apporder/Order_service.php diff --git a/admin/controllers/app/liche/Main.php b/admin/controllers/app/liche/Main.php index b9528932..b57c6a5f 100644 --- a/admin/controllers/app/liche/Main.php +++ b/admin/controllers/app/liche/Main.php @@ -63,6 +63,18 @@ class Main extends HD_Controller //array('name' => '查看详情', 'url' => '/sys/company?app_id=' . $this->app_id), ), ); + + //消费订单 + $this->load->model('apporder/order_purchase_model'); + $value = $this->order_purchase_model->count(array('app_id' => $this->app_id)); + $list[] = array( + 'title' => '消费订单(笔)', + 'value' => $value, + 'btns' => array( + array('name' => '查看详情', 'url' => '/order/purchase?app_id=' . $this->app_id), + ), + ); + $conditions[] = array('icon' => 'am-icon-home', 'list' => $list); /*小程序设置 end*/ diff --git a/admin/controllers/order/Purchase.php b/admin/controllers/order/Purchase.php new file mode 100644 index 00000000..62096e18 --- /dev/null +++ b/admin/controllers/order/Purchase.php @@ -0,0 +1,143 @@ +load->model('app/app_model'); + $this->load->model('apporder/order_purchase_model'); + + $this->load->service('apporder/order_service'); + } + + public function index() + { + return $this->lists(); + } + + public function lists() + { + $params = $this->input->get(); + $params['page'] = $params['page'] ? intval($params['page']) : 1; + $params['size'] = $params['size'] ? intval($params['size']) : 20; + + $searchAry = array( + 'sid' => '订单号', + 'uname' => '买家姓名', + 'mobile' => '买家手机号', + 'item_title' => '标题', + 'app_uid' => '用户ID' + ); + + $statusAry = $this->order_service->statusAry(); + $statusDAry = $this->order_service->statusDetailAry(); + $paywayAry = $this->order_service->paywayAry(); + + $where = array('app_id' => $params['app_id']); + + if($params['search_v']){ + switch($params['search_k']){ + case 'uname': + case 'mobile': + case 'item_title': + $where["{$params['search_k']} like '%{$params['search_v']}%'"] = null; + break; + default: + $where[$params['search_k']] = $params['search_v']; + } + } + !$params['search_k'] && $params['search_k'] = 'sid'; + + if($params['status']){ + $where['status'] = $params['status']; + } else { + $params['status'] = ''; + } + + if($params['status_detail']){ + $where['status_detail'] = $params['status_detail']; + } else{ + $params['status_detail'] = ''; + } + + if ($params['time']) { + $time = explode(' ~ ', $params['time']); + $time[0] && $where["c_time >="] = strtotime($time[0] . ' 00:00:00'); + $time[1] && $where["c_time <="] = strtotime($time[1] . ' 23:59:59'); + } + + if (strlen($params['payway']) > 0) { + $where['payway'] = $params['payway']; + } else { + $params['payway'] = ''; + } + + $total = $this->order_purchase_model->count($where); + + $lists = array(); + if($total){ + $orderby = 'id desc'; + $select = 'id,sid,item_title,item_num,item_price,total_price,pay_price, + uname,mobile,payway,status,status_detail,c_time'; + $rows = $this->order_purchase_model->select($where, $orderby, $params['page'], $params['size'], $select); + foreach($rows as $v){ + $lists[] = array( + 'id' => $v['id'], + 'sid' => $v['sid'], + 'uname' => $v['uname'], + 'mobile' => $v['mobile'], + 'title' => $v['item_title'], + 'c_time' => date('Y-m-d H:i:s', $v['c_time']), + 'item_price_name' => "¥{$v['item_price']}*{$v['item_num']}", + 'pay_price_name' => "¥{$v['pay_price']}", + 'status_name' => $statusDAry[$v['status']][$v['status_detail']], + 'payway_name' => $paywayAry[$v['payway']], + ); + } + } + + $this->data['_title'] = '消费订单管理'; + $this->data['searchAry'] = $searchAry; + $this->data['statusAry'] = $statusAry; + $this->data['statusDAry'] = $statusDAry; + $this->data['paywayAry'] = $paywayAry; + $this->data['pager'] = array('count' => ceil($total / $params['size']), 'curr' => $params['page'], 'totle' => $total); + $this->data['lists'] = $lists; + $this->data['params'] = $params; + return $this->show_view('/order/purchase/lists', true); + } + + public function get(){ + // TODO: Implement get() method. + } + + public function add(){ + // TODO: Implement add() method. + } + + public function edit(){ + // TODO: Implement edit() method. + } + + public function del(){ + // TODO: Implement del() method. + } + + public function batch(){ + // TODO: Implement batch() method. + } + + public function export(){ + // TODO: Implement export() method. + } + + +} diff --git a/admin/views/order/purchase/lists.php b/admin/views/order/purchase/lists.php new file mode 100644 index 00000000..3c8b6dc4 --- /dev/null +++ b/admin/views/order/purchase/lists.php @@ -0,0 +1,187 @@ +
+ + + diff --git a/common/services/apporder/Order_service.php b/common/services/apporder/Order_service.php new file mode 100644 index 00000000..5bae055e --- /dev/null +++ b/common/services/apporder/Order_service.php @@ -0,0 +1,133 @@ + array("11" => '待支付', "12" => '超时未支付', "13" => '已取消'), + //20,28复合订单才用到 + '2' => array('20' => '进行中', "21" => '待核销', "22" => '已核销', "23" => '核销码过期未退款', "24" => '核销码过期已退款', "25" => '待发货', "26" => '待收货', "27" => '已收货', '28' => '已完成'), + '3' => array("31" => '申请退款', "32" => '退款中', "33" => '已退款', "34" => '退款失败', '35' => '部分退款') + ); + + /** + * 一级状态 + * @var array + */ + protected static $statusAry = array('1' => '支付环节', '2' => '支付后环节', '3' => '申请退款'); + + /** + * 支付方式 + * @var array + */ + protected static $paywayAry = array('1' => '账户余额', '2' => '微信', '3' => '支付宝', '4' => '银联', '5' => '市民优选', '6' => '农行', '7' => '微信-银商','8'=> '云闪付'); + + /** + * 物流 + * @var array + */ + protected static $expressAry = array( + '0' => '自提', '1' => '顺丰速运', '2' => '百世快递', '3' => '中通快递', '4' => '申通快递', '5' => '圆通速递', '6' => '韵达速递', '7' => '邮政快递包裹' + , '8' => 'EMS', '9' => '天天快递', '10' => '京东物流', '11' => '国通快递', '12' => '优速快递', '13' => '德邦', '14' => '快捷快递' + , '15' => '宅急送', '16' => '安捷快递', '17' => '亚马逊物流' + ); + + function __construct($param = array()){ + parent::__construct(); + + $this->log_dir = lcfirst(get_class($this)) . "_" . $this->app_id; + + $this->load->model('app/app_model'); + $this->load->library('hd_exception'); + + if($param['app_id']){ + $this->init($param['app_id']); + } + } + + function init($app_id){ + $this->app_id = $app_id; + $this->log_dir = lcfirst(get_class($this)) . "_" . $this->app_id; + } + + /** + * 获取状态值,默认取二维数组 + * @param null $k1 取二级状态列表 + * @param null $k2 和k1一起取具体的状态值 + * @return array|mixed + */ + public function statusDetailAry($k1 = null, $k2 = null){ + $ary = self::$statusDetailAry; + $v = $this->ary($ary, $k1, $k2); + + return $v; + } + + /** + * 一级状态,默认数数组 + * @param null $k + * @return array|mixed + */ + function statusAry($k = null){ + $ary = self::$statusAry; + $v = $this->ary($ary, $k); + + return $v; + } + + /** + * 获取支付类型,默认取数组 + * @param null $k + * @return array|mixed + */ + function paywayAry($k = null){ + $ary = self::$paywayAry; + + $v = $this->ary($ary, $k); + + return $v; + } + + /** + * 获取物流 + * @param null $k + * @return mixed + */ + public function expressAry($k = null) + { + $ary = self::$expressAry; + + $v = $this->ary($ary, $k); + + return $v; + } + + /** + * @param $ary + * @param $k1 + * @param $k2 + * @return mixed + */ + private function ary($ary, $k1 = null, $k2 = null){ + if($k1 && $k2){ + $v = $ary[$k1][$k2]; + } elseif($k1) { + $v = $ary[$k1]; + } else { + $v = $ary; + } + + return $v; + } +}