// +---------------------------------------------------------------------- namespace App\Services\Common; use App\Models\AcceptorModel; use App\Models\TradeModel; use App\Services\BaseService; use Illuminate\Support\Facades\DB; /** * 承兑商管理-服务类 * @author laravel开发员 * @since 2020/11/11 * @package App\Services\Common */ class TradeService extends BaseService { /** * 构造函数 * @author laravel开发员 * @since 2020/11/11 */ public function __construct() { $this->model = new TradeModel(); } /** * 获取列表 * @param $params 参数 * @param int $pageSize 分页大小:默认 15 * @return array */ public function getDataList($params, $pageSize = 10, $field = []) { $where = ['a.mark' => 1]; if (isset($params['status']) && $params['status'] != '') { $where['a.status'] = $params['status']; } if (isset($params['type']) && $params['type'] != '') { $where['a.type'] = $params['type']; } if (isset($params['pay_type']) && $params['pay_type'] != '') { $where['a.pay_type'] = $params['pay_type']; } if (isset($params['pay_status']) && $params['pay_status'] != '') { $where['a.pay_status'] = $params['pay_status']; } if (isset($params['exception_status']) && $params['exception_status'] != '') { $where['a.exception_status'] = $params['exception_status']; } if (isset($params['cancel_type']) && $params['cancel_type'] != '') { $where['a.cancel_type'] = $params['cancel_type']; } $list = $this->model->with(['member', 'acceptor']) ->from('trade as a') ->leftJoin('member as b', 'b.id', 'a.user_id') ->leftJoin('acceptor as c', 'c.id', 'a.acceptor_id') ->where($where) ->where(function ($query) use ($params) { $word = isset($params['user']) ? trim($params['user']) : ''; if ($query) { $query->where('b.username', 'like', "%{$word}%")->orWhere('b.realname', 'like', "%{$word}%")->orWhere('b.nickname', 'like', "%{$word}%"); } }) ->where(function ($query) use ($params) { $word = isset($params['acceptor']) ? trim($params['acceptor']) : ''; if ($query) { $query->where('c.name', 'like', "%{$word}%")->orWhere('a.real_name', 'like', "%{$word}%"); } }) ->select($field ? $field : ['a.*', 'b.username']) ->paginate($pageSize > 0 ? $pageSize : 9999999); $list = $list ? $list->toArray() : []; if ($list) { foreach ($list['data'] as &$item) { if (!empty($item['pay_img'])) { $info['pay_img'] = isValidUrl($item['pay_img']) ? $item['pay_img'] : get_image_url($item['pay_img']); } } } return [ 'pageSize' => $pageSize, 'total' => isset($list['total']) ? $list['total'] : 0, 'list' => isset($list['data']) ? $list['data'] : [] ]; } /** * 添加会编辑会员 * @return array * @since 2020/11/11 * @author laravel开发员 */ public function edit() { // 请求参数 $data = request()->all(); return parent::edit($data); // TODO: Change the autogenerated stub } }