=', 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]; } public static function userMoneyLists($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[] = ['sn', '=', $keyword]; } elseif ($get['search_key'] == 'nickname') { $where[] = ['nickname', 'like', '%' . $keyword . '%']; } } $lists = User::where('del','0') ->field('id,nickname,avatar, sn as user_sn, mobile,user_money,earnings') ->where($where) ->page($page, $limit) ->select(); $count = User::where('del','0') ->field('id,nickname,avatar, sn as user_sn, mobile,user_money,earnings') ->where($where) ->count(); foreach ($lists as &$item){ $withdraw = WithdrawApply::where('user_id',$item['id'])->select(); $item['avatar'] = UrlServer::getFileUrl($item['avatar']); $item['withdraw_way'] =0; $item['withdraw_yet'] =0; if(isset($withdraw)){ foreach ($withdraw as $key=>$value){ if($value['status'] == 2){ $item['withdraw_way'] += $value['money']; } if($value['status'] == 3){ $item['withdraw_yet'] += $value['money']; } } } } return ['count' => $count, 'lists' => $lists]; } }