lip 1 сар өмнө
parent
commit
ee44aff896

+ 67 - 0
app/admin/command/Operation.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace app\admin\command;
+
+use think\console\Command;
+use app\admin\model\Operation as OperationModel;
+use app\admin\model\Recharge;
+use app\admin\model\Withdraw;
+use app\admin\model\Order;
+use app\admin\model\User;
+use think\console\Input;
+use think\console\Output;
+
+class Operation extends Command
+{
+    public function configure()
+    {
+        $this->setName('operation')
+            ->setDescription('统计昨日的充值提现订单等数据(每天00:00 之后执行)');
+    }
+
+    public function execute(Input $input, Output $output)
+    {
+        echo ('开始执行统计充值提现订单等数据任务...');
+
+        $this->addYesterdayOperationData();
+        echo ('结束执行统计充值提现订单等数据任务');
+    }
+
+    public function addYesterdayOperationData()
+    {
+        $yesterday = date('Y-m-d', strtotime('-1 day'));
+        $data = [
+            'date' => $yesterday,
+            'recharge' => 0,
+            'user_total_money' => 0,
+        ];
+        $start_time = strtotime($yesterday . ' 00:00:00');
+        $end_time = strtotime($yesterday . ' 23:59:59');
+
+        $data['recharge'] = Recharge::where('status', 1)
+            ->where('operation_time', '>=', $start_time)
+            ->where('operation_time', '<=', $end_time)
+            ->sum('actual_received');
+
+        $data['withdraw'] = Withdraw::where('status', 1)
+            ->where('operation_time', '>=', $start_time)
+            ->where('operation_time', '<=', $end_time)
+            ->sum('actual_received');
+
+        $data['balance_difference'] = $data['recharge'] - $data['withdraw'];
+        $data['total_price'] = Order::where('create_time', '>=', $start_time)
+            ->where('create_time', '<=', $end_time)
+            ->whereIn('status', [1, 2, 3, 4, 5])->sum('amount');
+
+        $data['user_total_money'] = User::sum('money');
+
+        $info = OperationModel::where('date', $data['date'])->find();
+        if ($info) {
+            OperationModel::update($data, ['date' => $data['date']]);
+        } else {
+            OperationModel::create($data);
+        }
+        return true;
+    }
+
+}

+ 79 - 0
app/admin/controller/Banner.php

@@ -0,0 +1,79 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\BaseController;
+
+use app\admin\model\Banner as BannerModel;
+use Exception;
+use think\facade\Db;
+
+class Banner extends BaseController
+{
+
+    /**
+     * 删除轮播
+     */
+    function delete()
+    {
+        Db::startTrans();
+        try {
+            $id = $this->request->param('id');
+            $banner = BannerModel::findOrFail($id);
+            $banner->delete();
+            DB::commit();
+        } catch (Exception $e) {
+            DB::rollBack();
+            return $this->error($e->getMessage());
+        }
+        return $this->success();
+    }
+
+    /**
+     * 编辑轮播
+     */
+    function update()
+    {
+        $errors = [];
+        Db::startTrans();
+        try {
+            $params = $this->request->param();
+            $params['id'] = $this->request->param('id', 0);
+            $id = $params['id'];
+            unset($params['id']);
+            $params['link'] = isset($params['link']) ? $params['link'] : '';
+            $params['remarks'] = isset($params['remarks']) ? $params['remarks'] : '';
+            $params['img_url'] = replacePartInUrl($params['img_url']);
+            if ($id > 0) {
+                BannerModel::where('id', $id)->update($params);
+            } else {
+                BannerModel::create($params);
+            }
+            Db::commit();
+        } catch (Exception $e) {
+            Db::rollBack();
+            return $this->error($e->getMessage(), $errors);
+        }
+        return $this->success();
+    }
+
+    /**
+     * 首页轮播
+     */
+    public function index()
+    {
+        try {
+            $page = $this->request->param('page', 1);
+            $limit = $this->request->param('limit', 15);
+            $count = BannerModel::count();
+            $list = BannerModel::limit($limit)
+                ->page($page)
+                ->order('sort','asc')
+                ->select()->toArray();
+
+        } catch (Exception $e) {
+            return $this->error($e->getMessage());
+        }
+        return $this->success(['count' => $count, 'list' => $list]);
+    }
+}

+ 104 - 0
app/admin/controller/Currency.php

@@ -0,0 +1,104 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\BaseController;
+use app\admin\model\Currency as CurrencyModel;
+use app\admin\validate\CurrencyValidate;
+use Exception;
+use think\facade\Db;
+
+class Currency extends BaseController
+{
+
+    /**
+     * 删除
+     */
+    function delete()
+    {
+        Db::startTrans();
+        try {
+            $id = $this->request->param('id');
+            $count = CurrencyModel::where('id', $id)->delete();
+            if ($count < 1) throw new Exception('操作失败');
+            Db::commit();
+        } catch (Exception $e) {
+            Db::rollBack();
+            return $this->error($e->getMessage());
+        }
+        return $this->success('删除成功');
+    }
+
+    /**
+     * 更新
+     */
+    public function update()
+    {
+        $errors = [];
+        Db::startTrans();
+        try {
+            $params = (new CurrencyValidate)->post()->goCheck('edit');
+            if (!empty($params['id'])) {
+                if (CurrencyModel::where('id', "<>", $params['id'])
+                    ->where('currency', $params['currency'])->value('id')) {
+                    $errors = ['currency' => $params['currency']];
+                    throw new Exception('已存在');
+                }
+                $chain = CurrencyModel::where('id', $params['id'])->find();
+                if (!$chain) {
+                    $errors = ['id' => $params['id']];
+                    throw new Exception('不存在');
+                }
+                unset($params['id']);
+                $chain->update($params);
+            } else {
+                if (CurrencyModel::where('currency', $params['currency'])->value('id')) {
+                    $errors = [
+                        'currency' => $params['currency'],
+                    ];
+                    throw new Exception('已存在');
+                }
+                unset($params['id']);
+                CurrencyModel::create($params);
+            }
+            Db::commit();
+        } catch (Exception $e) {
+            Db::rollBack();
+            return $this->error($e->getMessage(), $errors);
+        }
+        return $this->success();
+    }
+
+    /**
+     * 列表
+     */
+    function list()
+    {
+        try {
+            $params = $this->request->param();
+            $page = $params['page'] ?? 1;
+            $limit = $params['limit'] ?? 15;
+            $query = new CurrencyModel();
+            if (!empty($params['currency'])) {
+                $query->where('currency', 'like', "%{$params['currency']}%");
+            }
+            if (!empty($params['short_currency'])) {
+                $query->where('short_currency', 'like', "%{$params['short_currency']}%");
+            }
+            if (!empty($params['id'])) {
+                $query->where('id', $params['id']);
+            }
+            $count = $query->count();
+            $list = $query
+                ->limit($limit)
+                ->page($page)
+                ->order('currency', 'asc')
+                ->select()->toArray();
+        } catch (Exception $e) {
+            return $this->error($e->getMessage());
+        }
+        return $this->success(['count' => $count, 'list' => $list]);
+
+
+    }
+}

+ 96 - 0
app/admin/controller/DepositAddress.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\BaseController;
+use app\admin\model\DepositAddress;
+use app\admin\validate\DepositAddressValidate;
+use Exception;
+use think\facade\Db;
+
+class DepositAddresses extends BaseController
+{
+
+    /**
+     * 区块链地址删除
+     */
+    function delete()
+    {
+        Db::startTrans();
+        try {
+            $params = $this->request->param();
+            $count = DepositAddress::where('id', $params['id'])->delete();
+            if ($count < 1) throw new Exception('操作失败');
+            Db::commit();
+        } catch (Exception $e) {
+            Db::rollBack();
+            return $this->error($e->getMessage());
+        }
+        return $this->success();
+    }
+
+    /**
+     *  /blockChain/update 区块链地址更新
+     */
+    public function update()
+    {
+        $errors = [];
+        Db::startTrans();
+        try {
+            $params = (new DepositAddressValidate)->post()->goCheck('edit');
+            $params['operator_id'] = $this->admin_id;
+            $params['security_code'] = $params['security_code'] ?? '';
+            $params['withdraw_fee'] = $params['withdraw_fee'] ?? 0;
+            if (!empty($params['id'])) {
+                if (DepositAddress::where('id', "<>", $params['id'])
+                    ->where('currency', $params['currency'])
+                    ->where('network_type', $params['network_type'])->value('id')) {
+                    $errors = ['currency' => $params['currency'], 'network_type' => $params['network_type']];
+                    throw new Exception('区块链地址已存在');
+                }
+                $chain = DepositAddress::findOrFail($params['id']);
+                unset($params['id']);
+                $chain->update($params);
+            } else {
+                if (DepositAddress::where('currency', $params['currency'])
+                    ->where('network_type', $params['network_type'])->value('id')) {
+                    $errors = [
+                        'currency' => $params['currency'],
+                        'network_type' => $params['network_type']
+                    ];
+                    throw new Exception('区块链地址已存在');
+                }
+                unset($params['id']);
+                DepositAddress::create($params);
+            }
+            Db::commit();
+        } catch (Exception $e) {
+            Db::rollBack();
+            return $this->error($e->getMessage(), $errors);
+        }
+        return $this->success();
+    }
+
+    /**
+     * 区块链地址列表
+     */
+    function index()
+    {
+        try {
+            $page = $this->request->param('page', 1);
+            $limit = $this->request->param('limit', 15);
+            $query = new DepositAddress();
+            $count = $query->count();
+            $list = $query
+                ->limit($limit)
+                ->page($page)
+                ->order('currency','asc')
+                ->selete()->toArray();
+        } catch (Exception $e) {
+            return $this->error($e->getMessage());
+        }
+        return $this->success(['count' => $count, 'list' => $list]);
+
+
+    }
+}

+ 6 - 6
app/admin/controller/Operation.php

@@ -103,9 +103,9 @@ class Operation extends BaseController
             $query = new OperationModel;
             $query1 = new OperationModel;
             if (!empty($params['start_time'])) {
-                $query->where('date', '>=', $params['start_time'])
+                $query = $query->where('date', '>=', $params['start_time'])
                     ->where('date', '<=', $params['end_time']);
-                $query1->where('date', '>=', $params['start_time'])
+                $query1 = $query1->where('date', '>=', $params['start_time'])
                     ->where('date', '<=', $params['end_time']);
             } else if ($params['type'] != 'all') {
                 switch ($params['type']) {
@@ -113,14 +113,14 @@ class Operation extends BaseController
                         $date = date('Y-m-d');
                         break;
                     case "week":
-                        $date = Carbon::now()->startOfWeek()->format('Y-m-d');
+                        $date = date('Y-m-d', strtotime('this week'));
                         break;
                     case "month":
-                        $date = Carbon::now()->firstOfMonth()->format('Y-m-d');
+                        $date = date('Y-m-d', strtotime('this month'));
                         break;
                 }
-                $query->where('date', '>=', $date);
-                $query1->where('date', '>=', $date);
+                $query = $query->where('date', '>=', $date);
+                $query1 = $query1->where('date', '>=', $date);
             }
             $data['recharge'] = $query1->sum('recharge');
             $data['withdraw'] = $query1->sum('withdraw');

+ 47 - 277
app/admin/controller/Order.php

@@ -18,7 +18,7 @@ class Order extends BaseController
     public function adminRefund()
     {
         $errors = [];
-        DB::beginTransaction();
+        Db::startTrans();
         try {
             $params = $this->request->param();
             
@@ -66,17 +66,17 @@ class Order extends BaseController
     public function refund()
     {
         $errors = [];
-        DB::beginTransaction();
+        Db::startTrans();
         try {
             $params = $this->request->param();
-            $orderId = $params['order_id'];
+            $order_id = $params['order_id'];
             $safeWord = $params['safe_word'];
             $admin = Admin::where('id', $this->admin_id)->findOrFail();
             if (!password_verify($safeWord, $admin->payment_password)) throw new Exception('资金密码错误');
-            $order = OrderModel::where('id', $orderId)->findOrFail();
+            $order = OrderModel::where('id', $order_id)->findOrFail();
             if (!$order) throw new Exception('订单不存在');
             if ($order->return_status != 1 || $order->pay_status != 1) {
-                $errors = ['id' => $orderId];
+                $errors = ['id' => $order_id];
                 throw new Exception("该订单状态无法操作");
             }
             
@@ -97,9 +97,9 @@ class Order extends BaseController
             $user->money = $balanceAfter;
             $user->save();
 
-            DB::commit();
+            Db::commit();
         } catch (Exception $e) {
-            DB::rollBack();
+            Db::rollBack();
             return $this->error($e->getMessage(), $errors);
         }
         return $this->success();
@@ -113,12 +113,12 @@ class Order extends BaseController
     public function rejection()
     {
         $errors = [];
-        DB::beginTransaction();
+        Db::startTrans();
         try {
             $params = $this->request->param();
             if (empty($params['failure_msg'])) $params['failure_msg'] = '';
 
-            $order = OrderModel::where('id', $params['order_id'])->first();
+            $order = OrderModel::where('id', $params['order_id'])->findOrFail();
             if (!$order) throw new Exception('订单不存在');
             if ($order->status != 1 || $order->return_status != 1) {
                 $errors = ['id' => $params['order_id']];
@@ -127,155 +127,71 @@ class Order extends BaseController
             $order->return_operation_time = time();
             $order->failure_msg = $params['failure_msg'];
             $order->save();
-            DB::commit();
+            Db::commit();
         } catch (Exception $e) {
-            DB::rollBack();
+            Db::rollBack();
             return $this->error($e->getMessage(), $errors);
         }
         return $this->success();
     }
 
     /**
-     * @api {get} /order/list 订单列表
-     * @apiGroup 订单管理
-     * @apiVersion 1.0.0
-     * @apiUse header
-     * @apiUse lang
-     *
-     * @apiParam {int} [page=1]
-     * @apiParam {int} [limit=15]
-     * @apiParam {String} [id] 订单编号
-     * @apiParam {String} [user_id] 买家ID
-     * @apiParam {String} [store_id] 卖家ID
-     * @apiParam {String} [phone] 手机号
-     * @apiParam {String} [contacts] 收货人
-     * @apiParam {int=0,1} [pay_status] 支付状态 0待支付 1已支付
-     * @apiParam {int=0,1} [profit_status] 利润发放 0未发放 1已发放
-     * @apiParam {String} [start_time] 开始时间
-     * - 格式:`yyyy-mm-dd`
-     * @apiParam {String} [end_time] 开始时间
-     * - 格式:`yyyy-mm-dd`
-     * @apiParam {int=-1,0,1,2,3,4,5,6,7} [type=7] 订单类别
-     * - `7 全部订单`,`0 待付款`,`1 已确认`,`2 待发货`,`3 待收货`,`4 已收货`,`5 已评价`,`6 已退款`,`-1 已取消`
-     * @apiSuccess {String} id 订单编号
-     * @apiSuccess {Object} store 店铺信息
-     * @apiSuccess {String} store.user_id 店铺ID
-     * @apiSuccess {String} store.seller_name 店铺名
-     * @apiSuccess {String} store.seller_img 店铺logo
-     * @apiSuccess {String} store.seller_address 店铺地址
-     * @apiSuccess {String} contacts 收货人姓名
-     * @apiSuccess {String} user_id 买家ID
-     * @apiSuccess {String} store_id 卖家ID
-     * @apiSuccess {String} total_cost 采购价格
-     * @apiSuccess {String} price_count 订单金额
-     * @apiSuccess {String} profit 利润
-     * @apiSuccess {int} pay_status 支付状态 0待支付 1已支付
-     * @apiSuccess {int} status 订单状态
-     * -    -1      已取消
-     * -    0       待付款
-     * -    1       待发货
-     * -    2       待发货
-     * -    3       待收货
-     * -    4       已确认
-     * -    5       已评价
-     *
+     * 订单列表
      */
-    public function getList(Request $request)
+    public function list()
     {
         try {
-            $params = request()->validate([
-                'page' => ['nullable', 'integer', 'min:1'],
-                'limit' => ['nullable', 'integer', 'min:1'],
-                'id' => ['nullable', 'string'],
-                'user_id' => ['nullable', 'string'],
-                'store_id' => ['nullable', 'string'],
-                'phone' => ['nullable', 'string'],
-                'contacts' => ['nullable', 'string'],
-                'pay_status' => ['nullable', 'integer', 'in:0,1'],
-                'return_status' => ['nullable', 'integer', 'in:0,1,2,3'],
-                'purchase_status' => ['nullable', 'integer', 'in:0,1,2'],
-                'purchase_amount_status' => ['nullable', 'integer', 'in:0,1'],
-                'profit_status' => ['nullable', 'integer', 'in:0,1'],
-                'status' => ['nullable', 'integer', 'in:0,1,2,3,4,5,6,7,-1'],
-                'start_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:end_time'],
-                'end_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:start_time'],
-                'order_task_id' => ['nullable', 'string'],
-                'type' => ['nullable', 'integer', 'in:1,2'],
-            ]);
-            $page = request()->input('page', 1);
-            $limit = request()->input('limit', 15);
+            $params = $this->request->param();
+            $page = $this->request->param('page', 1);
+            $limit = $this->request->param('limit', 15);
 
-            $admin_id = $request->user->id;
-            if ($admin_id != 1 && Config::adminOpenAllData($admin_id) === false) {
-                $user_code = $request->user->user_code;
-                $query = OrderModel::leftJoin('users', 'orders.user_id', '=', 'users.user_id')
-                    ->leftJoin('users as stores', 'orders.store_id', '=', 'stores.user_id')
-                    ->where(function ($query) use ($user_code){
-                        $query->where('users.user_code', $user_code)
-                            ->orWhere('stores.user_code', $user_code);
-                    });
-            } else {
-                $query = OrderModel::query();
-            }
-           
+            $query = new OrderModel();
             if (!empty($params['start_time'])) {
-                $query = $query->where('orders.created_at', '>=', $params['start_time'] . " 00:00:00")
-                    ->where('orders.created_at', '<=', $params['end_time'] . " 23:59:59");
+                $startTime = strtotime($params['start_time'] . " 00:00:00");
+                $query = $query->where('create_time', '>=', $startTime);
             }
-            if (!empty($params['id'])) {
-                $query = $query->where('orders.id', $params['id']);
-            }
-            if (!empty($params['user_id'])) {
-                $query = $query->where('orders.user_id', $params['user_id']);
+            if (!empty($params['end_time'])) {
+                $endTime = strtotime($params['end_time'] . " 23:59:59");
+                $query = $query->where('create_time', '<=', $endTime);
             }
-            if (!empty($params['store_id'])) {
-                $query = $query->where('orders.store_id', $params['store_id']);
+            if (!empty($params['id'])) {
+                $query = $query->where('id', $params['id']);
             }
-            if (!empty($params['phone'])) {
-                $query = $query->where('orders.phone', $params['phone']);
+            if (!empty($params['order_id'])) {
+                $query = $query->where('order_id', $params['order_id']);
             }
-            if (!empty($params['contacts'])) {
-                $query = $query->where('orders.contacts', 'like', '%' . $params['contacts'] . '%');
+            if (!empty($params['user_id'])) {
+                $query = $query->where('user_id', $params['user_id']);
             }
             if (isset($params['status'])) {
-                $query = $query->where('orders.status', $params['status']);
+                $query = $query->where('status', $params['status']);
             }
             if (isset($params['return_status'])) {
-                $query = $query->where('orders.return_status', $params['return_status']);
+                $query = $query->where('return_status', $params['return_status']);
             }
             if (isset($params['pay_status'])) {
-                $query = $query->where('orders.pay_status', $params['pay_status']);
-            }
-            if (isset($params['profit_status'])) {
-                $query = $query->where('orders.profit_status', $params['profit_status']);
+                $query = $query->where('pay_status', $params['pay_status']);
             }
-            if (isset($params['purchase_status'])) {
-                $query = $query->where('orders.purchase_status', $params['purchase_status']);
+            if (isset($params['is_win'])) {
+                $query = $query->where('is_win', $params['is_win']);
             }
-            if (isset($params['purchase_amount_status'])) {
-                $query = $query->where('orders.purchase_amount_status', $params['purchase_amount_status']);
+            if (isset($params['settlement_status'])) {
+                $query = $query->where('settlement_status', $params['settlement_status']);
             }
-            if (!empty($params['order_task_id'])) {
-                $query = $query->where('orders.order_task_id', $params['order_task_id']);
-            }
-            if (!empty($params['type'])) {
-                $query = $query->where('orders.type', $params['type']);
+            if (isset($params['is_roll'])) {
+                $query = $query->where('is_roll', $params['is_roll']);
             }
 
             $count = $query->count();
-            $list = $query->with(['store', 'orderLog'])
-                ->select('orders.*')
-                ->forPage($page, $limit)
-                ->orderByDesc('orders.created_at')
-                ->get();
-
-
-        } catch (ValidationException $e) {
-            return $this->error($e->validator->errors()->first());
+            $list = $query
+                ->limit($limit)
+                ->page($page)
+                ->order('create_time', 'desc')
+                ->select();
         } catch (Exception $e) {
             return $this->error($e->getMessage());
         }
-        return $this->success(['count' => $count, 'stateList' => OrderShip::getStateList(), 'list' => $list]);
+        return $this->success(['count' => $count, 'list' => $list]);
 
     }
 
@@ -283,163 +199,17 @@ class Order extends BaseController
     function info()
     {
         try {
-            request()->validate([
-                'order_id' => ['required', 'string', 'min:19', 'max:19'],
-            ]);
-            $orderId = request()->input('order_id');
-            $order = OrderModel::with(['store'])->where('id', $orderId)->first();
+            $order_id = $this->request->param('order_id');
+            $order = OrderModel::where('order_id', $order_id)->findOrFail();
             if (!$order) throw new Exception('订单不存在');
             $order = $order->toArray();
+            $order['detail'] = json_decode($order['detail'],true);
+            $order['game_result']  = $order['game_result'] ? json_decode($order['game_result'],true) : null;
             ksort($order);
-            
-            //订单的商品列表
-            $list = OrderItem::where('order_id', $orderId)
-                ->get()->makeHidden(['total_cost', 'system_price', 'profit'])
-                ->toArray();
-            
-            foreach ($list as &$item) {
-                $goodsLanguages = GoodsLanguages::where('goods_id', $item['goods_id'])
-                    ->get()->toArray();
-                $goodsLanguages = Util::getDataByLanguageCode($goodsLanguages, $this->lang);
-                $item['goods_name'] = $goodsLanguages['name'];
-                $sku = GoodsSku::where('sku_id', $item['sku_id'])->first();
-                if (empty($sku)) {
-                    $item['cover_img'] = '';
-                    $item['attributes'] = [];
-                } else {
-                    $sku = $sku->toArray();
-                    $item['cover_img'] = $sku['cover_img'];
-                    $item['attributes'] = AttrValue::getAttr($sku['attr_value_ids'], $this->lang);
-                }
-            }
-            $order['goods'] = $list;
-
-            //退款驳回的原因
-            $order['failure_msg'] = '';
-            if ($order['return_status'] == 3) {
-                $order['failure_msg'] = OrderRefund::where('order_id', $orderId)->pluck('failure_msg')->first();
-            }
-        } catch (ValidationException $e) {
-            return $this->error($e->validator->errors()->first());
         } catch (Exception $e) {
             return $this->error($e->getMessage());
         }
-        $order['stateList'] = OrderShip::getStateList();
-        $order['ship_time'] = OrderShip::where(['order_id' => $orderId, 'state' => 3])->value('created_at');
         return $this->success($order);
     }
 
-    /**
-     * @api {post} /order/ship 发货
-     * @apiGroup 订单管理
-     * @apiVersion 1.0.0
-     * @apiUse header
-     * @apiUse lang
-     *
-     * @apiParam {String[]} order_id 订单id
-     */
-    public function ship()
-    {
-        $errors = [];
-        DB::beginTransaction();
-        try {
-            $params = request()->validate([
-                'order_id' => ['required', 'array', 'min:1'],
-                'order_id.*' => ['string', 'min:19', 'max:19'],
-            ]);
-            $orderIds = $params['order_id'];
-
-            foreach ($orderIds as $orderId) {
-                $order = OrderModel::where('id', $orderId)->first();
-                if (!$order) continue;
-                if ($order->pay_status != 1 ) {
-                    continue;
-                    // $errors = ['id' => $orderId];
-                    // throw new Exception("当前订单未支付");
-                }
-                if ($order->purchase_status != 1 ) {
-                    continue;
-                    // $errors = ['id' => $orderId];
-                    // throw new Exception("当前订单未采购");
-                }
-                if ($order->status != 2 ) {
-                    continue;
-                    // $errors = ['id' => $orderId];
-                    // throw new Exception("当前订单未到待发货状态");
-                }
-                if ($order->return_status != 0 ) {
-                    continue;
-                    // $errors = ['id' => $orderId];
-                    // throw new Exception("当前订单已申请退款");
-                }
-                $order->status = 3;
-                $order->ship_state = 3;
-                $order->save();
-                OrderLog::addData([
-                    'order_id' => $order->id,
-                    'state' => 7
-                ]);
-    
-                //记录物流
-                OrderShip::addData($order->id, 3);
-            }
-            DB::commit();
-        } catch (ValidationException $e) {
-            DB::rollBack();
-            return $this->error($e->validator->errors()->first());
-        } catch (Exception $e) {
-            DB::rollBack();
-            return $this->error($e->getMessage(), $errors);
-        }
-        return $this->success();
-    }
-
-    public function updateOrderShip()
-    {
-        try {
-
-            $params = request()->validate([
-                'order_id' => ['required', 'string', 'min:19', 'max:19'],
-                'state' => ['required', 'integer', 'in:4,5,6,7,8,9'],
-            ]);
-            $orderId = $params['order_id'];
-            $state = $params['state'];
-            $order = OrderModel::where('id', $orderId)->first();
-            if (!$order) throw new Exception('订单不存在');
-            if ($order->status < 3 ) {
-                throw new Exception("当前订单未到已发货状态");
-            }   
-            
-            Db::beginTransaction();
-            $order->ship_state = $state;
-            $order->save();
-          
-            OrderShip::addData($order->id, $state);
-            Db::commit();
-        }  catch (ValidationException $e) {
-            return $this->error($e->validator->errors()->first());
-        } catch (Exception $e) {
-            Db::rollBack();
-            return $this->error($e->getMessage());
-        }
-        return $this->success();
-    }
-
-    //查看订单物流
-    public function orderShip()
-    {
-        try {
-            $params = request()->validate([
-                'order_id' => ['required', 'string', 'min:19', 'max:19'],
-            ]);
-            $orderId = $params['order_id'];
-            
-            $ship = OrderModel::getOrderShip($orderId);
-        }  catch (ValidationException $e) {
-            return $this->error($e->validator->errors()->first());
-        } catch (Exception $e) {
-            return $this->error($e->getMessage());
-        }
-        return $this->success($ship);
-    }
 }

+ 23 - 39
app/admin/controller/Wallet.php

@@ -75,7 +75,7 @@ class Wallet extends BaseController
     function rechargeRefuse()
     {
         $errors = [];
-        DB::beginTransaction();
+        Db::startTrans();
         try {
             $params = (new WalletValidate())->post()->goCheck('rechargeRefuse');
             $operationRemark = $params['operation_remark'] ?? '';
@@ -88,9 +88,9 @@ class Wallet extends BaseController
             $ro->operation_remark = $operationRemark;
             $ro->operation_time = time();
             $ro->save();
-            DB::commit();
+            Db::commit();
         } catch (Exception $e) {
-            DB::rollBack();
+            Db::rollBack();
             return $this->error($e->getMessage(), $errors);
         }
         return $this->success();
@@ -162,7 +162,7 @@ class Wallet extends BaseController
     function withdrawRefuse()
     {
         $errors = [];
-        DB::beginTransaction();
+        Db::startTrans();
         try {
             $params = (new WalletValidate())->post()->goCheck('withdrawRefuse');
             $operationRemark = $params['operation_remark'] ?? '';
@@ -182,13 +182,14 @@ class Wallet extends BaseController
             ]);
             $wo->status = 2;
             $wo->operation_remark = $operationRemark;
+            $wo->operator_id = $this->admin_id;
             $wo->operation_time = time();
             $wo->save();
             $user->money = $userMoney;
             $user->save();
-            DB::commit();
+            Db::commit();
         } catch (Exception $e) {
-            DB::rollBack();
+            Db::rollBack();
             return $this->error($e->getMessage(), $errors);
         }
         return $this->success();
@@ -209,7 +210,7 @@ class Wallet extends BaseController
     function withdrawPass()
     {
         $errors = [];
-        DB::beginTransaction();
+        Db::startTrans();
         try {
             $params = (new WalletValidate())->post()->goCheck('withdrawPass');
             $safeWord = $params['safe_word'] ?? '';
@@ -221,11 +222,12 @@ class Wallet extends BaseController
                 throw new Exception("该订单状态无法操作");
             }
             $wo->operation_time = date('Y-m-d H:i:s');
+            $wo->operator_id = $this->admin_id;
             $wo->status = 1;
             $wo->save();
-            DB::commit();
+            Db::commit();
         } catch (Exception $e) {
-            DB::rollBack();
+            Db::rollBack();
             return $this->error($e->getMessage(), $errors);
         }
         return $this->success();
@@ -237,7 +239,7 @@ class Wallet extends BaseController
     function updateAddress()
     {
         $errors = [];
-        DB::beginTransaction();
+        Db::startTrans();
         try {
             $params = (new WalletValidate())->post()->goCheck('updateAddress');
             $admin = Admin::where('id', $this->admin_id)->find();
@@ -254,9 +256,9 @@ class Wallet extends BaseController
             }
             $wo->save();
 
-            DB::commit();
+            Db::commit();
         } catch (Exception $e) {
-            DB::rollBack();
+            Db::rollBack();
             return $this->error($e->getMessage(), $errors);
         }
         return $this->success();
@@ -267,11 +269,11 @@ class Wallet extends BaseController
      */
     public function rechargeAddress()
     {
-        $list = DepositAddress::select(['currency', 'network_type', 'deposit_address', 'withdraw_fee','is_withdraw'])->get()->toArray();
+        $list = DepositAddress::field(['currency', 'network_type', 'address', 'withdraw_fee','is_withdraw'])->select()->toArray();
         $list[] = [
             'currency' => '银行卡',
             'network_type' => 'BANK',
-            'deposit_address' => '',
+            'address' => '',
             'withdraw_fee' => '0.00',
             'is_withdraw'   => 0,
         ];
@@ -279,27 +281,7 @@ class Wallet extends BaseController
     }
 
     /**
-     * @api {get} /wallet/withdraws 提现订单
-     * @apiGroup 财务
-     * @apiVersion 1.0.0
-     * @apiUse header
-     * @apiUse lang
-     *
-     * @apiParam {int} [page=1]
-     * @apiParam {int} [limit=15]
-     *
-     * @apiParam {String} [order_no] 订单号(完整)
-     * @apiParam {String} [username] 用户名、user_id
-     * @apiParam {String} [method] 订单类型
-     * - 通过 <a href="javascript:;" onclick="toMenu('财务','GetWalletRechargeaddress')">订单类型</a> 获取
-     * @apiParam {String} [create_start] 创建开始日期
-     * - 格式:yyyy-mm-dd
-     * @apiParam {String} [create_end] 创建结束日期
-     * - 格式:yyyy-mm-dd
-     * @apiParam {String} [operation_start] 审核开始日期
-     * - 格式:yyyy-mm-dd
-     * @apiParam {String} [operation_end] 审核结束日期
-     * - 格式:yyyy-mm-dd
+     * 提现订单
      */
     public function withdraws()
     {
@@ -307,7 +289,6 @@ class Wallet extends BaseController
             $params = $this->request->param();
             $page = isset($params['page']) ? intval($params['page']) : 1;
             $limit = isset($params['limit']) ? intval($params['limit']) : 15;
-
             $query = Withdraw::alias('withdraw')->join('user', 'withdraw.user_id=user.user_id','left');
            
             if (isset($params['start_time'])) {
@@ -332,6 +313,9 @@ class Wallet extends BaseController
             if (!empty($params['order_no'])) {
                 $query->where('withdraw.order_no', $params['order_no']);
             }
+            if (!empty($params['currency'])) {
+                $query->where('withdraw.currency', $params['currency']);
+            }
             if (!empty($params['realname'])) {
                 $query = $query->where(function ($query) use ($params) {
                     $query->where('user.realname', 'like', "%{$params['realname']}%")
@@ -360,7 +344,7 @@ class Wallet extends BaseController
      */
     public function changeMoney()
     {
-        DB::startTrans();
+        Db::startTrans();
         try {
             $params = $this->request->param();
             $admin = request()->user;
@@ -424,9 +408,9 @@ class Wallet extends BaseController
                     $user->save();
                     break;
             }
-            DB::commit();
+            Db::commit();
         } catch (Exception $e) {
-            DB::rollBack();
+            Db::rollBack();
             return $this->error($e->getMessage());
         }
         return $this->success();

+ 12 - 0
app/admin/model/Banner.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace app\admin\model;
+
+use app\BaseModel;
+
+class Banner extends BaseModel
+{
+    protected $autoWriteTimestamp = true;
+    protected $createTime = 'create_time';
+    protected $updateTime = 'update_time';
+}

+ 12 - 0
app/admin/model/Currency.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace app\admin\model;
+
+use app\BaseModel;
+
+class Currency extends BaseModel
+{
+    protected $autoWriteTimestamp = true;
+    protected $createTime = 'create_time';
+    protected $updateTime = 'update_time';
+}

+ 3 - 1
app/admin/model/Operation.php

@@ -7,6 +7,8 @@ use app\BaseModel;
 
 class Operation extends BaseModel
 {
-    
+    protected $autoWriteTimestamp = true;
+    protected $createTime = 'create_time';
+    protected $updateTime = 'update_time';
 
 }

+ 1 - 1
app/admin/model/Order.php

@@ -6,7 +6,7 @@ use app\BaseModel;
 
 class Order extends BaseModel
 {
-    protected $table = 'sport_order';
+    protected $table = 'la_sport_order';
     protected $autoWriteTimestamp = true;
     protected $createTime = 'create_time';
     protected $updateTime = 'update_time';

+ 47 - 0
app/admin/validate/BannerValidate.php

@@ -0,0 +1,47 @@
+<?php
+
+
+namespace app\admin\validate;
+
+
+class BannerValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'title' => 'nullable',
+        'image' => 'require',
+        'link' => 'nullable',
+        'type' => 'nullable',
+        'sort' => 'nullable|numeric',
+    ];
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'title' => '标题',
+        'image' => '图片',
+        'link' => '链接',
+        'type' => '类型',
+        'sort' => '排序',
+    ];
+
+    /**
+     * @notes 编辑场景
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','title', 'image', 'link', 'type', 'sort']);
+    }
+
+    public function sceneId()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 43 - 0
app/admin/validate/CurrencyValidate.php

@@ -0,0 +1,43 @@
+<?php
+
+
+namespace app\admin\validate;
+
+
+class CurrencyValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'currency' => 'require',
+        'short_currency' => 'require',
+        'img' => 'require',
+    ];
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'currency' => '币种',
+        'short_currency' => '短币种',
+        'img' => '图标',
+    ];
+
+    /**
+     * @notes 编辑场景
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','currency', 'short_currency', 'img']);
+    }
+
+    public function sceneId()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 49 - 0
app/admin/validate/DepositAddressValidate.php

@@ -0,0 +1,49 @@
+<?php
+
+
+namespace app\admin\validate;
+
+
+class DepositAddressValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'currency' => 'require',
+        'network_type' => 'require',
+        'address' => 'require',
+        'security_code' => 'nullable',
+        'withdraw_fee' => 'nullable|numeric|min:0|max:0.99|regex:/^\d+(\.\d{1,2})?$/',
+        'is_withdraw' => 'require|integer|in:1,0',
+    ];
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'currency' => '币种',
+        'network_type' => '网络类型',
+        'address' => '地址',
+        'security_code' => '安全码',
+        'withdraw_fee' => '提现手续费',
+        'is_withdraw' => '是否开启提现',
+    ];
+
+    /**
+     * @notes 编辑场景
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','currency', 'network_type', 'address', 'security_code', 'withdraw_fee', 'is_withdraw']);
+    }
+
+    public function sceneId()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 4 - 0
app/lang/zh.php

@@ -276,4 +276,8 @@ return [
     '投注' => '投注',
     '资金冻结' => '资金冻结',
     '退款' => '退款',
+    '已存在' => '已存在',
+    '不存在' => '不存在',
+    '区块链地址已存在' => '区块链地址已存在',
+    '余额不足' => '余额不足',
 ];

+ 2 - 0
config/console.php

@@ -10,8 +10,10 @@ return [
         'queue:Restart' => think\queue\command\Restart::class,
         'task' => task\command\Task::class,
         'worker:gateway' => app\worker\command\GatewayWorker::class,
+        'operation' => app\admin\command\Operation::class,
         'operation:data' => app\admin\command\OperationData::class,
         'user:timeout' => app\admin\command\UserTimeout::class,
         'user:queue' => app\admin\command\UserQueue::class,
+
     ],
 ];