|
|
@@ -0,0 +1,134 @@
|
|
|
+<?php
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Laravel框架 [ Laravel ]
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 版权所有 2017~2021 Laravel研发中心
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 官方网站: http://www.laravel.cn
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Author: wesmiler <12345678@qq.com>
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+
|
|
|
+namespace App\Services;
|
|
|
+
|
|
|
+use App\Models\MemberModel;
|
|
|
+use App\Models\RechargeModel;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 提现记录管理-服务类
|
|
|
+ * @author wesmiler
|
|
|
+ * @since 2020/11/11
|
|
|
+ * Class WithdrawService
|
|
|
+ * @package App\Services
|
|
|
+ */
|
|
|
+class WithdrawService extends BaseService
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ * @author wesmiler
|
|
|
+ * @since 2020/11/11
|
|
|
+ * WithdrawService constructor.
|
|
|
+ */
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ $this->model = new RechargeModel();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取列表
|
|
|
+ * @return array
|
|
|
+ * @since 2020/11/11
|
|
|
+ * @author wesmiler
|
|
|
+ */
|
|
|
+ public function getList()
|
|
|
+ {
|
|
|
+ $params = request()->all();
|
|
|
+ $page = isset($params['pageSize']) ? intval($params['pageSize']) : PAGE;
|
|
|
+ $pageSize = isset($params['pageSize']) ? intval($params['pageSize']) : PERPAGE;
|
|
|
+
|
|
|
+ $dataList = $this->model::from('withdraw_logs as a')
|
|
|
+ ->leftJoin('member as m', 'm.id', '=', 'a.user_id')
|
|
|
+ ->where(function ($query) use ($params) {
|
|
|
+ $query->where('a.mark', 1);
|
|
|
+
|
|
|
+ $type = isset($params['type']) ? $params['type'] : 0;
|
|
|
+ if ($type > 0) {
|
|
|
+ $query->where('a.type', $type);
|
|
|
+ }
|
|
|
+
|
|
|
+ $payType = isset($params['pay_type']) ? $params['pay_type'] : 0;
|
|
|
+ if ($payType > 0) {
|
|
|
+ $query->where('a.pay_type', $payType);
|
|
|
+ }
|
|
|
+
|
|
|
+ $userId = isset($params['user_id']) ? $params['user_id'] : 0;
|
|
|
+ if ($userId > 0) {
|
|
|
+ $query->where('a.user_id', $userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ $datetime = isset($params['datetime'])? $params['datetime'] : [];
|
|
|
+ $dateStart = $datetime && isset($datetime[0])? $datetime[0] : '';
|
|
|
+ $dateEnd = isset($datetime[1])? $datetime[1] : '';
|
|
|
+ if($dateStart && $dateEnd && $dateEnd> $dateStart){
|
|
|
+ $query->where('a.create_time', '>', strtotime($dateStart))->where('a.create_time','<=', strtotime($dateEnd)+86399);
|
|
|
+ }else if($dateStart && $dateStart == $dateEnd){
|
|
|
+ $query->where('a.create_time', '>=', strtotime($dateStart))->where('a.create_time','<=', strtotime($dateStart)+86399);
|
|
|
+ }else if ($dateStart){
|
|
|
+ $query->where('a.create_time', '<=', strtotime($dateStart)+86399);
|
|
|
+ }
|
|
|
+
|
|
|
+ $status = isset($params['status']) ? $params['status'] : 0;
|
|
|
+ if ($status > 0) {
|
|
|
+ $query->where('a.status', $status);
|
|
|
+ } else {
|
|
|
+ $query->whereIn('a.status', [1, 2]);
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ ->where(function ($query) use ($params) {
|
|
|
+ $keyword = isset($params['keyword']) ? trim($params['keyword']) : '';
|
|
|
+ if (!empty($keyword)) {
|
|
|
+ $query->where('m.nickname','like',"%{$keyword}%")
|
|
|
+ ->orWhere('a.order_sn','like',"%{$keyword}%");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->select(['a.id', 'a.user_id','a.order_sn','a.trade_no','a.pay_at', 'm.nickname','a.realname','a.account','a.qrcode','a.type','a.pay_type','a.money', 'a.balance', 'a.status', 'a.create_time', 'a.update_time','a.remark'])
|
|
|
+ ->orderBy('a.create_time', 'desc')
|
|
|
+ ->paginate($pageSize);
|
|
|
+
|
|
|
+ $dataList = $dataList ? $dataList->toArray() : [];
|
|
|
+ if ($dataList) {
|
|
|
+ foreach ($dataList['data'] as &$item) {
|
|
|
+ $item['create_time'] = $item['create_time'] ? datetime($item['create_time'],'Y-m-d H:i:s') : '';
|
|
|
+ }
|
|
|
+ unset($item);
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'code' => 0,
|
|
|
+ 'success'=> true,
|
|
|
+ 'msg' => '操作成功',
|
|
|
+ 'count' => isset($dataList['total']) ? $dataList['total'] : 0,
|
|
|
+ 'data' => isset($dataList['data']) ? $dataList['data'] : 0,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加或编辑
|
|
|
+ * @return array
|
|
|
+ * @since 2020/11/11
|
|
|
+ * @author wesmiler
|
|
|
+ */
|
|
|
+ public function edit()
|
|
|
+ {
|
|
|
+ $data = request()->all();
|
|
|
+ $data['update_time'] = time();
|
|
|
+ return parent::edit($data); // TODO: Change the autogenerated stub
|
|
|
+ }
|
|
|
+
|
|
|
+ public function withdraw($userId){
|
|
|
+ $params = request()->all();
|
|
|
+
|
|
|
+ }
|
|
|
+}
|