get(); } else { $list = $sql->simplePaginate(getProp($param, 'limit', 15)); } if (!$list->isEmpty()) { foreach ($list as $val) { $val->username = $val->user_id > 0 ? User::where('id', $val->user_id)->value('username') : ""; $val->company_name = "-"; $val->play_name = '-'; $company = Miniprogram::where('id', $val->miniprogram_id)->first(); if ($company) { $val->company_name = $company->company(); $val->play_name = $company->play_name; } $val->promotion_title = $val->promotion_id > 0 ? DB::table('promotions')->where('id', $val->promotion_id)->value('name') : ""; $val->total_count = Order::where('uid',$val->uid)->where('id',"<=",$val->id)->count(); if ($val->user_id > 0){ $val->caompany_count = Order::where('uid',$val->uid)->where('puser_id','>',0)->where('puser_id',$val->puser_id)->where('id',"<=",$val->id)->count(); $val->promotion_count = Order::where('uid',$val->uid)->where('puser_id','>',0)->where('puser_id',$val->puser_id)->where('user_id',">",0)->where('user_id',$val->user_id)->where('id',"<=",$val->id)->count(); }else{ $val->caompany_count = Order::where('uid',$val->uid)->where('puser_id','>',0)->count(); $val->promotion_count = Order::where('uid',$val->uid)->where('user_id','>',0)->count(); } $val->tip_text = self::getOrderType()[$val->order_type] ?? "-"; $val->status_txt = self::getOrderPayType()[$val->status] ?? "-"; $val->pay_name = '微信支付'; } } return $list; } public static function getOrderType(){ return [ "COIN" => "普通充值", 'MONTH'=>'包月', 'QUARTER'=>'包季', 'YEAR'=>'包年', "FIRST_COIN" => "首冲" ]; } public static function getOrderPayType(){ return [ "PAID" => "已支付", 'REFUND'=>'已退款', 'UNPAID'=>'未支付', ]; } private static function getOrderQuerySql(array $param) { $sql = Order::query(); // 优化师查询 if (!empty(getProp($param, 'user_id'))) { $sql->where('user_id', $param['user_id']); } // 公司查询 if (!empty(getProp($param, 'puser_id'))) { $sql->where('puser_id', $param['puser_id']); } // 小程序 if (!empty(getProp($param, 'miniprogram_id'))) { $sql->where('miniprogram_id', $param['miniprogram_id']); } // 推广id if (!empty(getProp($param, 'promotion_id'))) { $sql->where('promotion_id', $param['promotion_id']); } // 订单状态查询 if (!empty(getProp($param, 'status'))) { $sql->where('status', $param['status']); } // 充值项类型 if (!empty(getProp($param, 'order_type'))) { $sql->where('order_type', $param['order_type']); } // 用户 if (!empty(getProp($param, 'uid'))) { $sql->where('uid', $param['uid']); } // 订单号查询 if (!empty(getProp($param, 'trade_no'))) { $sql->where('trade_no', "like", "%" . $param['trade_no'] . "%"); // $sql->where('trade_no', $param['trade_no']); } if (!empty(getProp($param, 'trade_no'))) { // $sql->where('trade_no', "like", "%" . $param['trade_no'] . "%"); $sql->where('trade_no', $param['trade_no']); } if (!empty(getProp($param, 'pay_end_at_start'))) { $sql->where('pay_end_at', $param['pay_end_at_start']); } if (!empty(getProp($param, 'pay_end_at_end'))) { $sql->where('pay_end_at', "<=", $param['pay_end_at_end']); } return $sql; } }