|
|
@@ -4,7 +4,6 @@ namespace App\Services\Common;
|
|
|
|
|
|
use App\Models\BalanceLogModel;
|
|
|
use App\Models\MemberModel;
|
|
|
-use App\Models\AgentModel;
|
|
|
use App\Models\StoreModel;
|
|
|
use App\Services\BaseService;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
@@ -15,6 +14,7 @@ use Illuminate\Support\Facades\DB;
|
|
|
*/
|
|
|
class BalanceLogsService extends BaseService
|
|
|
{
|
|
|
+
|
|
|
/**
|
|
|
* 获取列表
|
|
|
* @param array $params 请求参数
|
|
|
@@ -293,6 +293,126 @@ class BalanceLogsService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 列表
|
|
|
+ * @param $params
|
|
|
+ * @param int $pageSize
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getDataList($params, $pageSize = 10)
|
|
|
+ {
|
|
|
+ $where = ['a.mark' => 1];
|
|
|
+ $list = $this->model->from('balance_logs as a')
|
|
|
+ ->leftJoin('member as b','b.id','=','a.user_id')
|
|
|
+ ->leftJoin('driver as c','c.id','=','a.user_id')
|
|
|
+ ->where($where)
|
|
|
+ ->where(function ($query) use($params){
|
|
|
+ $userType = isset($params['user_type'])? $params['user_type'] : 0;
|
|
|
+ if($userType == 1){
|
|
|
+ $query->where('a.user_type', $userType);
|
|
|
+
|
|
|
+ $keyword = isset($params['keyword'])? $params['keyword'] : '';
|
|
|
+ if($keyword){
|
|
|
+ $query->where(function($query) use($keyword){
|
|
|
+ $query->where('a.order_no','like',"%{$keyword}%")->orWhere('b.nickname','like',"%{$keyword}%")->orWhere('b.mobile','like',"%{$keyword}%");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }else if ($userType == 2){
|
|
|
+ $query->where('a.user_type', $userType);
|
|
|
+
|
|
|
+ $keyword = isset($params['keyword'])? $params['keyword'] : '';
|
|
|
+ if($keyword){
|
|
|
+ $query->where(function($query) use($keyword){
|
|
|
+ $query->where('a.order_no','like',"%{$keyword}%")->orWhere('c.realname','like',"%{$keyword}%")->orWhere('c.mobile','like',"%{$keyword}%");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->where(function ($query) use($params){
|
|
|
+ $status = isset($params['status'])? $params['status'] : 0;
|
|
|
+ if($status>0 && is_array($status)){
|
|
|
+ $query->whereIn('a.status', $status);
|
|
|
+ }else if($status){
|
|
|
+ $query->where('a.status', $status);
|
|
|
+ }
|
|
|
+
|
|
|
+ $type = isset($params['type'])? $params['type'] : 0;
|
|
|
+ if($type>0){
|
|
|
+ $query->where('a.type', $type);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->select(['a.*','b.nickname as user_nickname','b.realname as user_realname','b.mobile as user_mobile','c.realname as driver_name','c.mobile as driver_mobile','c.realname as driver_realname'])
|
|
|
+ ->orderBy('a.create_time','desc')
|
|
|
+ ->orderBy('a.id','desc')
|
|
|
+ ->paginate($pageSize > 0 ? $pageSize : 9999999);
|
|
|
+ $list = $list? $list->toArray() :[];
|
|
|
+ if($list){
|
|
|
+ foreach($list['data'] as &$item){
|
|
|
+ $item['create_time'] = $item['create_time']? datetime($item['create_time'],'Y-m-d H.i.s') : '';
|
|
|
+ $item['qrcode'] = $item['qrcode']? get_image_url($item['qrcode']) : '';
|
|
|
+ $item['account'] = $item['account']? json_decode($item['account'], true) : [];
|
|
|
+ $item['username'] = $item['user_nickname']? $item['user_nickname'].($item['user_mobile']?'-'.$item['user_mobile']:'') : '';
|
|
|
+ $item['driver'] = $item['driver_name']? $item['driver_name'].($item['driver_mobile']?'-'.$item['driver_mobile']:'') : '';
|
|
|
+ if($item['user_type'] == 2){
|
|
|
+ $item['realname'] = $item['realname']? $item['realname'] : $item['driver_realname'];
|
|
|
+ }else{
|
|
|
+ $item['realname'] = $item['realname']? $item['realname'] : $item['user_realname'];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'pageSize'=> $pageSize,
|
|
|
+ 'total'=>isset($list['total'])? $list['total'] : 0,
|
|
|
+ 'list'=> isset($list['data'])? $list['data'] : []
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计
|
|
|
+ * @param $params
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getCount($params)
|
|
|
+ {
|
|
|
+ $where = ['a.mark' => 1];
|
|
|
+ $model = $this->model->from('balance_logs as a')
|
|
|
+ ->leftJoin('member as b','b.id','=','a.user_id')
|
|
|
+ ->where($where)
|
|
|
+ ->where(function ($query) use($params){
|
|
|
+ $userType = isset($params['user_type'])? $params['user_type'] : 0;
|
|
|
+ if($userType == 1){
|
|
|
+ $query->where('a.user_type', $userType);
|
|
|
+
|
|
|
+ $keyword = isset($params['keyword'])? $params['keyword'] : '';
|
|
|
+ if($keyword){
|
|
|
+ $query->where(function($query) use($keyword){
|
|
|
+ $query->where('a.order_no','like',"%{$keyword}%")->orWhere('b.nickname','like',"%{$keyword}%")->orWhere('b.mobile','like',"%{$keyword}%");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->where(function ($query) use($params){
|
|
|
+ $status = isset($params['status'])? $params['status'] : 0;
|
|
|
+ if($status>0 && is_array($status)){
|
|
|
+ $query->whereIn('a.status', $status);
|
|
|
+ }else if($status){
|
|
|
+ $query->where('a.status', $status);
|
|
|
+ }
|
|
|
+
|
|
|
+ $type = isset($params['type'])? $params['type'] : 0;
|
|
|
+ if($type>0){
|
|
|
+ $query->where('a.type', $type);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $counts = [
|
|
|
+ 'count'=> $model->count('a.id'),
|
|
|
+ 'total'=> $model->sum('a.money'),
|
|
|
+ ];
|
|
|
+ return $counts;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 更新代理表的累计提现金额
|
|
|
*/
|
|
|
private function updateAgentWithdrawTotal($record)
|