From 65d8567c5afa9831155ac6e3b9c865fc883cc2dc Mon Sep 17 00:00:00 2001 From: Yao <734770036@qq.com> Date: Fri, 18 Oct 2024 13:43:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A2=E5=8A=A1=E7=BB=9F=E8=AE=A1=E5=95=86?= =?UTF-8?q?=E5=AE=B6=E6=B1=87=E6=80=BB=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/finance/Order.php | 96 +++ app/admin/logic/finance/FinanceLogic.php | 13 + app/admin/logic/finance/OrderLogic.php | 302 +++++++++ app/admin/view/finance/finance/center.html | 20 + app/admin/view/finance/order/lists.html | 625 ++++++++++++++++++ app/admin/view/finance/order/local_lists.html | 362 ++++++++++ 6 files changed, 1418 insertions(+) create mode 100644 app/admin/controller/finance/Order.php create mode 100644 app/admin/logic/finance/OrderLogic.php create mode 100644 app/admin/view/finance/order/lists.html create mode 100644 app/admin/view/finance/order/local_lists.html diff --git a/app/admin/controller/finance/Order.php b/app/admin/controller/finance/Order.php new file mode 100644 index 00000000..3297d503 --- /dev/null +++ b/app/admin/controller/finance/Order.php @@ -0,0 +1,96 @@ +request->isAjax()) { + $get = $this->request->get(); + return JsonServer::success('', OrderLogic::statistics($get)); + } + $data = OrderLogic::statistics(); + // 订单状态 + $order_status = OrderModel::getOrderStatus(true); + $order_status = OrderLogic::getStat($order_status); //拼装数量统计 + // 订单类型 + $order_type = OrderModel::getOrderType(true); + // 订单来源 + $order_source = Client_::getClient(true); + // 支付方式 + $pay_way = PayEnum::getPayWay(true); + // 配送方式 + $delivery_type = OrderModel::getDeliveryType(true); + $all = OrderLogic::getAll(); + $getLocalAll = OrderLogic::getLocalAll(); + return view('', [ + 'all' => $all, + 'getLocalAll'=>$getLocalAll, + 'statistics' => $data, + 'order_status' => $order_status, + 'order_type' => $order_type, + 'order_source' => $order_source, + 'pay_way' => $pay_way, + 'delivery_type' => $delivery_type + ]); + } + + + public function localLists(){ + + if ($this->request->isAjax()) { + $get = $this->request->get(); + return JsonServer::success('', OrderLogic::localLists($get)); + } + + $today = [ + date('Y-m-d H:i:s', strtotime(date("Y-m-d", time()))), + date('Y-m-d H:i:s', strtotime(date("Y-m-d", time())) + 86399) + ]; + + $yesterday = [ + date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-1 day")))), + date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-1 day"))) + 86399) + ]; + + + $days_ago7 = [ + date('Y-m-d H:i:s', strtotime(date("Y-m-d", strtotime("-7 day")))), + date('Y-m-d 23:59:59', time()) + ]; + + $days_ago30 = [ + date('Y-m-d 00:00:00', strtotime("-30 day")), + date('Y-m-d 23:59:59', time()) + ]; + $all = OrderLogic::getAll(); + $getLocalAll = OrderLogic::getLocalAll(); + return view('', array( + 'getLocalAll'=>$getLocalAll, + 'all'=>$all, + 'today' => $today, + 'yesterday' => $yesterday, + 'days_ago7' => $days_ago7, + 'days_ago30' => $days_ago30, + )); + + } + + +} \ No newline at end of file diff --git a/app/admin/logic/finance/FinanceLogic.php b/app/admin/logic/finance/FinanceLogic.php index b173c83b..6e6aa3af 100755 --- a/app/admin/logic/finance/FinanceLogic.php +++ b/app/admin/logic/finance/FinanceLogic.php @@ -69,6 +69,12 @@ class FinanceLogic extends Logic ['pay_status', '>', PayEnum::UNPAID] ]) ->count('id'); + $localAll = LocalStoreOrder::where([ + 'local_our_company'=>0, + 'state'=>1 + ])->count('id'); + + $orderNum = $orderNum+$localAll; //营业额 $orderAmount = $model @@ -77,6 +83,13 @@ class FinanceLogic extends Logic ['pay_status', '>', PayEnum::UNPAID] ]) ->sum('order_amount'); + $localAmount = LocalStoreOrder::where([ + 'local_our_company'=>0, + 'state'=>1 + ])->sum('total_amount'); + + $orderAmount = $orderAmount+$localAmount; + //退款订单金额 diff --git a/app/admin/logic/finance/OrderLogic.php b/app/admin/logic/finance/OrderLogic.php new file mode 100644 index 00000000..de6cdc42 --- /dev/null +++ b/app/admin/logic/finance/OrderLogic.php @@ -0,0 +1,302 @@ +=', strtotime($get['start_time'])]; + } + + if (isset($get['end_time']) && $get['end_time'] != '') { + $where[] = ['o.create_time', '<=', strtotime($get['end_time'])]; + } + + if (isset($get['page']) && $get['page'] != '') { + $page = $get['page']; + } + + if (isset($get['limit']) && $get['limit'] != '') { + $limit = $get['limit']; + } + + // 导出excel + if (true === $is_export) { + return self::export($where); + } + + $field = 'o.*,s.name as shop_name,u.level'; + + $count = $order + ->alias('o') + ->field($field) + ->join('shop s', 's.id = o.shop_id') + ->join('user u', 'u.id = o.user_id') + ->join('order_goods g', 'g.order_id = o.id') + ->with(['order_goods', 'user', 'shop']) + ->where($where) + ->where('o.pay_status', '>', PayEnum::UNPAID) + ->group('o.id') + ->count(); + + $lists = $order + ->alias('o') + ->field($field) + ->join('shop s', 's.id = o.shop_id') + ->join('user u', 'u.id = o.user_id') + ->join('order_goods g', 'g.order_id = o.id') + ->with(['order_goods', 'user', 'shop']) + ->where($where) + ->where('o.pay_status', '>', PayEnum::UNPAID) + ->append([ + 'delivery_address', 'pay_status_text', 'order_source_text', + 'order_status_text', 'delivery_type_text', 'order_type_text', + 'pay_way_text', + ]) + ->page($page, $limit) + ->order('o.id desc') + ->group('o.id') + ->select(); + + $user_level = UserLevel::where(['del' => 0])->column('name', 'id'); + + foreach ($lists as $list) { + $list['pay_time'] = $list['pay_time'] == '0' ? '未支付' : date('Y-m-d H:i:s', $list['pay_time']); + $list['user']['avatar'] = UrlServer::getFileUrl($list['user']['avatar']); + $list['shop']['logo'] = UrlServer::getFileUrl($list['shop']['logo']); + foreach ($list['order_goods'] as $order_good) { + $order_good['image'] = UrlServer::getFileUrl($order_good['image']); + } + + // 会员等级 + $list['user_level'] = '暂无等级'; + if (isset($user_level[$list['level']])) { + $list['user_level'] = $user_level[$list['level']]; + } + } + return ['count' => $count, 'lists' => $lists]; + } + + + /** + * @notes 拼装统计信息 + * @param $order_status + * @return array + * @author suny + * @date 2021/7/14 10:08 上午 + */ + public static function getStat($order_status) + { + foreach ($order_status as $key => $value) { + $num = Order::where('order_status', $key)->count('id'); + $stat = $value . "(" . $num . ")"; + $data[] = $stat; + } + return $data; + } + + /** + * @notes 获取各列表数量 + * @return int + * @author suny + * @date 2021/7/14 10:08 上午 + */ + public static function getAll() + { + $all = Order::where([ + ['pay_status', '>', PayEnum::UNPAID] + ]) + ->count('id'); + return $all; + } + + public static function getLocalAll(){ + $localAll = LocalStoreOrder::where([ + 'local_our_company'=>0, + 'state'=>1 + ])->count(); + return $localAll; + } + + + public static function localLists($get){ + + $page = $get['page'] ?? 1; + $limit = $get['limit'] ?? 10; + + $where = []; + // 会员信息 + if (!empty($get['search_key']) && !empty($get['keyword'])) { + $keyword = $get['keyword']; + if ($get['search_key'] == 'user_sn') { + $where[] = ['u.sn', '=', $keyword]; + } elseif ($get['search_key'] == 'nickname') { + $where[] = ['u.nickname', 'like', '%' . $keyword . '%']; + } + } + + //订单编号 + if (isset($get['order_no']) && $get['order_no'] != '') { + $where[] = ['w.order_no', 'like', '%' . $get['order_no']. '%']; + } + + //商家名称 + if (isset($get['shopName']) && $get['shopName'] != '') { + $where[] = ['s.shopName', 'like', '%' . $get['shopName']. '%']; + } + + + //支付方式 + if (isset($get['pay_way']) && $get['pay_way'] != '') { + $where[] = ['w.pay_way', '=', $get['pay_way']]; + } + + if (isset($get['start_time']) && $get['start_time'] && isset($get['end_time']) && $get['end_time']) { + $where[] = ['w.create_time', 'between', [$get['start_time'], $get['end_time']]]; + } + + + $lists = LocalStoreOrder::alias('w') + ->field('w.*, u.nickname,u.avatar, u.sn as user_sn, u.mobile,p.transaction_id,s.store_nickname,s.shopName,g.title,g.price') + ->leftJoin('user u', 'u.id = w.user_id') + ->leftJoin('local_pay p','w.order_no = p.order_sn') + ->leftJoin('local_store s','p.local_id = s.lstore_id') + ->leftJoin('local_store_goods g','p.goods_id = g.id') + ->where($where) + ->where([ + 'w.local_our_company' => 0, + 'w.state'=>1 + ]) + ->page($page, $limit) + ->order('w.id desc') + ->select(); + + $count = LocalStoreOrder::alias('w') + ->field('w.*, u.nickname,u.avatar, u.sn as user_sn, u.mobile,p.transaction_id,s.store_nickname,s.shopName,g.title,g.price') + ->leftJoin('user u', 'u.id = w.user_id') + ->leftJoin('local_pay p','w.order_no = p.order_sn') + ->leftJoin('local_store s','p.local_id = s.lstore_id') + ->leftJoin('local_store_goods g','p.goods_id = g.id') + ->where($where) + ->where([ + 'w.local_our_company' => 0, + 'w.state'=>1 + ]) + ->order('w.id desc') + ->count(); + + + + + foreach ($lists as &$item) { + $item['avatar'] = UrlServer::getFileUrl($item['avatar']); + $item['pay_way' ] = ($item['pay_way'] = 0)?'微信':'余额'; + } + + + + return ['count' => $count, 'lists' => $lists]; + + + } + + + + + +} \ No newline at end of file diff --git a/app/admin/view/finance/finance/center.html b/app/admin/view/finance/finance/center.html index 8b0031b6..06ec4398 100755 --- a/app/admin/view/finance/finance/center.html +++ b/app/admin/view/finance/finance/center.html @@ -181,6 +181,17 @@ +
+
+
+ 已成交订单明细(列表) +
+
+ +
+
+
+ @@ -480,6 +491,15 @@ }); }); + layui.use('jquery', function() { + var $ = layui.jquery; + $('#make-order').on('click', function() { + window.location.href = '{:url("finance.order/lists")}'; // 将 'your-target-page.html' 替换为你想要跳转的页面地址 + }); + }); + + + // 监听搜索 form.on('submit(account-search)', function (data) { var field = data.field; diff --git a/app/admin/view/finance/order/lists.html b/app/admin/view/finance/order/lists.html new file mode 100644 index 00000000..8037ee2f --- /dev/null +++ b/app/admin/view/finance/order/lists.html @@ -0,0 +1,625 @@ +{layout name="layout1" /} + + +
+
+
+ +
+
+ +
    +
  • 商城订单({$all})
  • +
  • 本地生活订单({$getLocalAll})
  • +
+
+
+
+
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+ + + +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ \ No newline at end of file diff --git a/app/admin/view/finance/order/local_lists.html b/app/admin/view/finance/order/local_lists.html new file mode 100644 index 00000000..032d7953 --- /dev/null +++ b/app/admin/view/finance/order/local_lists.html @@ -0,0 +1,362 @@ +{layout name="layout1" /} + + +
+
+
+ + + + + +
+
+ 本地生活订单汇总 +
+
+ +
+
+ + + +
+
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+
+ + + + +
+
+ +
+ + +
+
+
+
+
+
+
    +
  • 商城订单({$all})
  • +
  • 本地生活订单({$getLocalAll})
  • +
+
+
+ + + + + + + + + +
+
+
+
+
+
+