Просмотр исходного кода

所有decimal字段改int字段,本次更新请务必依次导入20171129.sql\20171130.sql\20171201.sql,或者备份数据后重建数据库

胖虎 8 лет назад
Родитель
Сommit
bd98fefdd9

+ 169 - 132
app/Http/Controllers/AdminController.php

@@ -53,8 +53,8 @@ class AdminController extends BaseController
         $flowCount = $this->flowAutoShow($flowCount);
         $view['flowCount'] = $flowCount;
         $view['totalBalance'] = User::query()->sum('balance') / 100;
-        $view['totalWaitRefAmount'] = ReferralLog::query()->whereIn('status', [0, 1])->sum('ref_amount');
-        $view['totalRefAmount'] = ReferralApply::query()->where('status', 2)->sum('amount');
+        $view['totalWaitRefAmount'] = ReferralLog::query()->whereIn('status', [0, 1])->sum('ref_amount') / 100;
+        $view['totalRefAmount'] = ReferralApply::query()->where('status', 2)->sum('amount') / 100;
         $view['expireWarningUserCount'] = User::query()->where('expire_time', '<=', date('Y-m-d', strtotime("+" . self::$config['expire_days'] . " days")))->where('enable', 1)->count();
 
         return Response::view('admin/index', $view);
@@ -165,31 +165,31 @@ class AdminController extends BaseController
             }
 
             $ret = User::query()->create([
-                'username' => $username,
-                'password' => $password,
-                'port' => $port,
-                'passwd' => empty($passwd) ? $this->makeRandStr() : $passwd, // SS密码为空时生成默认密码
+                'username'        => $username,
+                'password'        => $password,
+                'port'            => $port,
+                'passwd'          => empty($passwd) ? $this->makeRandStr() : $passwd, // SS密码为空时生成默认密码
                 'transfer_enable' => $this->toGB($transfer_enable),
-                'enable' => $enable,
-                'method' => $method,
-                'custom_method' => $method,
-                'protocol' => $protocol,
-                'protocol_param' => $protocol_param,
-                'obfs' => $obfs,
-                'obfs_param' => $obfs_param,
-                'gender' => $gender,
-                'wechat' => $wechat,
-                'qq' => $qq,
-                'usage' => $usage,
-                'pay_way' => $pay_way,
-                'balance' => 0,
-                'score' => 0,
-                'enable_time' => empty($enable_time) ? date('Y-m-d') : $enable_time,
-                'expire_time' => empty($expire_time) ? date('Y-m-d', strtotime("+365 days")) : $expire_time,
-                'remark' => $remark,
-                'level' => $level,
-                'is_admin' => $is_admin,
-                'reg_ip' => $request->getClientIp()
+                'enable'          => $enable,
+                'method'          => $method,
+                'custom_method'   => $method,
+                'protocol'        => $protocol,
+                'protocol_param'  => $protocol_param,
+                'obfs'            => $obfs,
+                'obfs_param'      => $obfs_param,
+                'gender'          => $gender,
+                'wechat'          => $wechat,
+                'qq'              => $qq,
+                'usage'           => $usage,
+                'pay_way'         => $pay_way,
+                'balance'         => 0,
+                'score'           => 0,
+                'enable_time'     => empty($enable_time) ? date('Y-m-d') : $enable_time,
+                'expire_time'     => empty($expire_time) ? date('Y-m-d', strtotime("+365 days")) : $expire_time,
+                'remark'          => $remark,
+                'level'           => $level,
+                'is_admin'        => $is_admin,
+                'reg_ip'          => $request->getClientIp()
             ]);
 
             if ($ret) {
@@ -244,30 +244,30 @@ class AdminController extends BaseController
             $is_admin = $request->get('is_admin');
 
             $data = [
-                'username' => $username,
-                'port' => $port,
-                'passwd' => $passwd,
-                'transfer_enable' => $this->toGB($transfer_enable),
-                'enable' => $status < 0 ? 0 : $enable, // 如果禁止登陆则同时禁用SSR
-                'method' => $method,
-                'custom_method' => $method,
-                'protocol' => $protocol,
-                'protocol_param' => $protocol_param,
-                'obfs' => $obfs,
-                'obfs_param' => $obfs_param,
-                'speed_limit_per_con' => $speed_limit_per_con,
+                'username'             => $username,
+                'port'                 => $port,
+                'passwd'               => $passwd,
+                'transfer_enable'      => $this->toGB($transfer_enable),
+                'enable'               => $status < 0 ? 0 : $enable, // 如果禁止登陆则同时禁用SSR
+                'method'               => $method,
+                'custom_method'        => $method,
+                'protocol'             => $protocol,
+                'protocol_param'       => $protocol_param,
+                'obfs'                 => $obfs,
+                'obfs_param'           => $obfs_param,
+                'speed_limit_per_con'  => $speed_limit_per_con,
                 'speed_limit_per_user' => $speed_limit_per_user,
-                'gender' => $gender,
-                'wechat' => $wechat,
-                'qq' => $qq,
-                'usage' => $usage,
-                'pay_way' => $pay_way,
-                'status' => $status,
-                'enable_time' => empty($enable_time) ? date('Y-m-d') : $enable_time,
-                'expire_time' => empty($expire_time) ? date('Y-m-d', strtotime("+365 days")) : $expire_time,
-                'remark' => $remark,
-                'level' => $level,
-                'is_admin' => $is_admin
+                'gender'               => $gender,
+                'wechat'               => $wechat,
+                'qq'                   => $qq,
+                'usage'                => $usage,
+                'pay_way'              => $pay_way,
+                'status'               => $status,
+                'enable_time'          => empty($enable_time) ? date('Y-m-d') : $enable_time,
+                'expire_time'          => empty($expire_time) ? date('Y-m-d', strtotime("+365 days")) : $expire_time,
+                'remark'               => $remark,
+                'level'                => $level,
+                'is_admin'             => $is_admin
             ];
 
             if (!empty($password)) {
@@ -369,37 +369,37 @@ class AdminController extends BaseController
             $status = $request->get('status');
 
             $node = SsNode::query()->create([
-                'name' => $name,
-                'group_id' => $group_id,
-                'country_code' => $country_code,
-                'server' => $server,
-                'desc' => $desc,
-                'method' => $method,
-                'custom_method' => $method,
-                'protocol' => $protocol,
-                'protocol_param' => $protocol_param,
-                'obfs' => $obfs,
-                'obfs_param' => $obfs_param,
-                'traffic_rate' => $traffic_rate,
-                'bandwidth' => $bandwidth,
-                'traffic' => $traffic,
-                'monitor_url' => $monitor_url,
-                'compatible' => $compatible,
-                'single' => $single,
-                'single_force' => $single ? $single_force : 0,
-                'single_port' => $single ? $single_port : '',
-                'single_passwd' => $single ? $single_passwd : '',
-                'single_method' => $single ? $single_method : '',
+                'name'            => $name,
+                'group_id'        => $group_id,
+                'country_code'    => $country_code,
+                'server'          => $server,
+                'desc'            => $desc,
+                'method'          => $method,
+                'custom_method'   => $method,
+                'protocol'        => $protocol,
+                'protocol_param'  => $protocol_param,
+                'obfs'            => $obfs,
+                'obfs_param'      => $obfs_param,
+                'traffic_rate'    => $traffic_rate,
+                'bandwidth'       => $bandwidth,
+                'traffic'         => $traffic,
+                'monitor_url'     => $monitor_url,
+                'compatible'      => $compatible,
+                'single'          => $single,
+                'single_force'    => $single ? $single_force : 0,
+                'single_port'     => $single ? $single_port : '',
+                'single_passwd'   => $single ? $single_passwd : '',
+                'single_method'   => $single ? $single_method : '',
                 'single_protocol' => $single ? $single_protocol : '',
-                'sort' => $sort,
-                'status' => $status,
+                'sort'            => $sort,
+                'status'          => $status,
             ]);
 
             // 建立分组关联
             if ($group_id) {
                 SsGroupNode::query()->create([
                     'group_id' => $group_id,
-                    'node_id' => $node->id
+                    'node_id'  => $node->id
                 ]);
             }
 
@@ -448,30 +448,30 @@ class AdminController extends BaseController
             $status = $request->get('status');
 
             $data = [
-                'name' => $name,
-                'group_id' => $group_id,
-                'country_code' => $country_code,
-                'server' => $server,
-                'desc' => $desc,
-                'method' => $method,
-                'custom_method' => $method,
-                'protocol' => $protocol,
-                'protocol_param' => $protocol_param,
-                'obfs' => $obfs,
-                'obfs_param' => $obfs_param,
-                'traffic_rate' => $traffic_rate,
-                'bandwidth' => $bandwidth,
-                'traffic' => $traffic,
-                'monitor_url' => $monitor_url,
-                'compatible' => $compatible,
-                'single' => $single,
-                'single_force' => $single ? $single_force : 0,
-                'single_port' => $single ? $single_port : '',
-                'single_passwd' => $single ? $single_passwd : '',
-                'single_method' => $single ? $single_method : '',
+                'name'            => $name,
+                'group_id'        => $group_id,
+                'country_code'    => $country_code,
+                'server'          => $server,
+                'desc'            => $desc,
+                'method'          => $method,
+                'custom_method'   => $method,
+                'protocol'        => $protocol,
+                'protocol_param'  => $protocol_param,
+                'obfs'            => $obfs,
+                'obfs_param'      => $obfs_param,
+                'traffic_rate'    => $traffic_rate,
+                'bandwidth'       => $bandwidth,
+                'traffic'         => $traffic,
+                'monitor_url'     => $monitor_url,
+                'compatible'      => $compatible,
+                'single'          => $single,
+                'single_force'    => $single ? $single_force : 0,
+                'single_port'     => $single ? $single_port : '',
+                'single_passwd'   => $single ? $single_passwd : '',
+                'single_method'   => $single ? $single_method : '',
                 'single_protocol' => $single ? $single_protocol : '',
-                'sort' => $sort,
-                'status' => $status
+                'sort'            => $sort,
+                'status'          => $status
             ];
 
             $ret = SsNode::query()->where('id', $id)->update($data);
@@ -483,7 +483,7 @@ class AdminController extends BaseController
 
                     SsGroupNode::query()->create([
                         'group_id' => $group_id,
-                        'node_id' => $id
+                        'node_id'  => $id
                     ]);
                 }
 
@@ -556,12 +556,12 @@ class AdminController extends BaseController
         }
 
         $view['trafficDaily'] = [
-            'nodeName' => $node->name,
+            'nodeName'  => $node->name,
             'dailyData' => "'" . implode("','", $dailyData) . "'"
         ];
 
         $view['trafficHourly'] = [
-            'nodeName' => $node->name,
+            'nodeName'   => $node->name,
             'hourlyData' => "'" . implode("','", $hourlyData) . "'"
         ];
 
@@ -598,12 +598,12 @@ class AdminController extends BaseController
             $sort = $request->get('sort');
 
             Article::query()->create([
-                'title' => $title,
-                'type' => $type,
-                'author' => $author,
+                'title'   => $title,
+                'type'    => $type,
+                'author'  => $author,
                 'content' => $content,
-                'is_del' => 0,
-                'sort' => $sort
+                'is_del'  => 0,
+                'sort'    => $sort
             ]);
 
             return Response::json(['status' => 'success', 'data' => '', 'message' => '添加成功']);
@@ -624,11 +624,11 @@ class AdminController extends BaseController
             $content = $request->get('content');
 
             $data = [
-                'title' => $title,
-                'type' => $type,
-                'author' => $author,
+                'title'   => $title,
+                'type'    => $type,
+                'author'  => $author,
                 'content' => $content,
-                'sort' => $sort
+                'sort'    => $sort
             ];
 
             $ret = Article::query()->where('id', $id)->update($data);
@@ -679,7 +679,7 @@ class AdminController extends BaseController
             $level = $request->get('level');
 
             SsGroup::query()->create([
-                'name' => $name,
+                'name'  => $name,
                 'level' => $level
             ]);
 
@@ -700,7 +700,7 @@ class AdminController extends BaseController
             $level = $request->get('level');
 
             $data = [
-                'name' => $name,
+                'name'  => $name,
                 'level' => $level
             ];
 
@@ -852,18 +852,18 @@ class AdminController extends BaseController
             $data = [];
             foreach ($content->port_password as $port => $passwd) {
                 $data[] = [
-                    'd' => 0,
-                    'enable' => 1,
-                    'method' => $method,
-                    'obfs' => $obfs,
-                    'obfs_param' => empty($obfs_param) ? "" : $obfs_param,
-                    'passwd' => $passwd,
-                    'port' => $port,
-                    'protocol' => $protocol,
-                    'protocol_param' => empty($protocol_param) ? "" : $protocol_param,
+                    'd'               => 0,
+                    'enable'          => 1,
+                    'method'          => $method,
+                    'obfs'            => $obfs,
+                    'obfs_param'      => empty($obfs_param) ? "" : $obfs_param,
+                    'passwd'          => $passwd,
+                    'port'            => $port,
+                    'protocol'        => $protocol,
+                    'protocol_param'  => empty($protocol_param) ? "" : $protocol_param,
                     'transfer_enable' => $this->toGB($transfer_enable),
-                    'u' => 0,
-                    'user' => date('Ymd') . '_IMPORT_' . $port,
+                    'u'               => 0,
+                    'user'            => date('Ymd') . '_IMPORT_' . $port,
                 ];
             }
 
@@ -1031,7 +1031,7 @@ class AdminController extends BaseController
             $txt .= "密码:" . ($node->single ? $node->single_passwd : $user->passwd) . "\r\n";
             $txt .= "加密方法:" . ($node->single ? $node->single_method : $user->method) . "\r\n";
             $txt .= "协议:" . ($node->single ? $node->single_protocol : $user->protocol) . "\r\n";
-            $txt .= "协议参数:" . ($node->single ? $user->port.':'.$user->passwd : $user->protocol_param) . "\r\n";
+            $txt .= "协议参数:" . ($node->single ? $user->port . ':' . $user->passwd : $user->protocol_param) . "\r\n";
             $txt .= "混淆方式:" . ($node->single ? 'tls1.2_ticket_auth' : $user->obfs) . "\r\n";
             $txt .= "混淆参数:" . ($node->single ? '' : $user->obfs_param) . "\r\n";
             $txt .= "本地端口:1080\r\n路由:绕过局域网及中国大陆地址";
@@ -1118,12 +1118,12 @@ class AdminController extends BaseController
             }
 
             $trafficDaily[$node->id] = [
-                'nodeName' => $node->name,
+                'nodeName'  => $node->name,
                 'dailyData' => "'" . implode("','", $dailyData) . "'"
             ];
 
             $trafficHourly[$node->id] = [
-                'nodeName' => $node->name,
+                'nodeName'   => $node->name,
                 'hourlyData' => "'" . implode("','", $hourlyData) . "'"
             ];
         }
@@ -1161,10 +1161,10 @@ class AdminController extends BaseController
             }
 
             SsConfig::query()->create([
-                'name' => $name,
-                'type' => $type,
+                'name'       => $name,
+                'type'       => $type,
                 'is_default' => $is_default,
-                'sort' => $sort
+                'sort'       => $sort
             ]);
 
             return Response::json(['status' => 'success', 'data' => '', 'message' => '添加成功']);
@@ -1271,7 +1271,7 @@ class AdminController extends BaseController
             }
 
             Level::query()->create([
-                'level' => $level,
+                'level'      => $level,
                 'level_name' => $level_name
             ]);
 
@@ -1596,6 +1596,12 @@ class AdminController extends BaseController
         }
 
         $list = $query->orderBy('id', 'desc')->paginate(10)->appends($request->except('page'));
+        if (!empty($list)) {
+            foreach ($list as $vo) {
+                $vo->amount = $vo->amount / 100;
+            }
+        }
+
         $view['applyList'] = $list;
 
         return Response::view('admin/applyList', $view);
@@ -1609,12 +1615,15 @@ class AdminController extends BaseController
         $list = [];
         $apply = ReferralApply::query()->where('id', $id)->with('user')->first();
         if ($apply && $apply->link_logs) {
+            $apply->amount = $apply->amount / 100;
             $link_logs = explode(',', $apply->link_logs);
             $list = ReferralLog::query()->whereIn('id', $link_logs)->with('user')->paginate(10);
         }
 
         foreach ($list as &$vo) {
             $vo->goods = OrderGoods::query()->where('oid', $vo->order_id)->with('goods')->first();
+            $vo->amount = $vo->amount / 100;
+            $vo->ref_amount = $vo->ref_amount / 100;
         }
 
         $view['info'] = $apply;
@@ -1667,23 +1676,24 @@ class AdminController extends BaseController
 
             try {
                 $user = User::query()->where('id', $user_id)->first();
+                $amount = $amount * 100;
 
                 // 写入余额变动日志
                 $userBalanceLog = new UserBalanceLog();
                 $userBalanceLog->user_id = $user_id;
                 $userBalanceLog->order_id = 0;
                 $userBalanceLog->before = $user->balance;
-                $userBalanceLog->after = $user->balance + $amount * 100;
-                $userBalanceLog->amount = $amount * 100;
+                $userBalanceLog->after = $user->balance + $amount;
+                $userBalanceLog->amount = $amount;
                 $userBalanceLog->desc = '后台手动充值';
                 $userBalanceLog->created_at = date('Y-m-d H:i:s');
                 $userBalanceLog->save();
 
                 // 加减余额
                 if ($amount < 0) {
-                    $user->decrement('balance', abs($amount * 100));
+                    $user->decrement('balance', abs($amount));
                 } else {
-                    $user->increment('balance', abs($amount * 100));
+                    $user->increment('balance', abs($amount));
                 }
 
                 return Response::json(['status' => 'success', 'data' => '', 'message' => '充值成功']);
@@ -1694,4 +1704,31 @@ class AdminController extends BaseController
             return Response::view('admin/handleUserBalance');
         }
     }
+
+    // 用户余额变动日志
+    public function userBalanceLogList(Request $request)
+    {
+        $username = trim($request->get('username'));
+
+        $query = UserBalanceLog::query()->with(['user'])->orderBy('id', 'desc');
+
+        if ($username) {
+            $query->whereHas('user', function ($q) use ($username) {
+                $q->where('username', 'like', '%' . $username . '%');
+            });
+        }
+
+        $list = $query->paginate(10);
+        if (!empty($list)) {
+            foreach ($list as &$vo) {
+                $vo->before = $vo->before / 100;
+                $vo->after = $vo->after / 100;
+                $vo->amount = $vo->amount / 100;
+            }
+        }
+
+        $view['list'] = $list;
+
+        return Response::view('admin/userBalanceLogList', $view);
+    }
 }

+ 7 - 2
app/Http/Controllers/CouponController.php

@@ -27,7 +27,12 @@ class CouponController extends BaseController
     // 优惠券列表
     public function couponList(Request $request)
     {
-        $view['couponList'] = Coupon::query()->where('is_del', 0)->orderBy('id', 'desc')->paginate(10);
+        $couponList = Coupon::query()->where('is_del', 0)->orderBy('id', 'desc')->paginate(10);
+        foreach ($couponList as $coupon) {
+            $coupon->amount = $coupon->amount / 100;
+        }
+
+        $view['couponList'] = $couponList;
 
         return Response::view('coupon/couponList', $view);
     }
@@ -76,7 +81,7 @@ class CouponController extends BaseController
                     $obj->logo = $logo;
                     $obj->type = $type;
                     $obj->usage = $usage;
-                    $obj->amount = empty($amount) ? 0 : $amount;
+                    $obj->amount = empty($amount) ? 0 : $amount * 100;
                     $obj->discount = empty($discount) ? 0 : $discount / 10;
                     $obj->available_start = strtotime(date('Y-m-d 0:0:0', strtotime($available_start)));
                     $obj->available_end = strtotime(date('Y-m-d 23:59:59', strtotime($available_end)));

+ 14 - 4
app/Http/Controllers/ShopController.php

@@ -24,7 +24,12 @@ class ShopController extends BaseController
     // 商品列表
     public function goodsList(Request $request)
     {
-        $view['goodsList'] = Goods::query()->where('is_del', 0)->orderBy('id', 'desc')->paginate(10);
+        $goodsList = Goods::query()->where('is_del', 0)->orderBy('id', 'desc')->paginate(10);
+        foreach ($goodsList as $goods) {
+            $goods->price = $goods->price / 100;
+        }
+
+        $view['goodsList'] = $goodsList;
 
         return Response::view('shop/goodsList', $view);
     }
@@ -63,7 +68,7 @@ class ShopController extends BaseController
             $obj->desc = $desc;
             $obj->logo = $logo;
             $obj->traffic = $traffic;
-            $obj->price = $price;
+            $obj->price = $price * 100; // 单位分
             $obj->score = $score;
             $obj->type = $type;
             $obj->days = $days;
@@ -118,7 +123,7 @@ class ShopController extends BaseController
                 'desc'    => $desc,
                 'logo'    => $logo,
                 'traffic' => $traffic,
-                'price'   => $price,
+                'price'   => $price * 100, // 单位分
                 'score'   => $score,
                 'type'    => $type,
                 'days'    => $days,
@@ -133,7 +138,12 @@ class ShopController extends BaseController
 
             return Redirect::to('shop/editGoods?id=' . $id);
         } else {
-            $view['goods'] = Goods::query()->where('id', $id)->first();
+            $goods = Goods::query()->where('id', $id)->first();
+            if (!empty($goods)) {
+                $goods->price = $goods->price / 100;
+            }
+
+            $view['goods'] = $goods;
 
             return Response::view('shop/editGoods', $view);
         }

+ 23 - 8
app/Http/Controllers/UserController.php

@@ -247,7 +247,12 @@ class UserController extends BaseController
     // 商品列表
     public function goodsList(Request $request)
     {
-        $view['goodsList'] = Goods::query()->where('status', 1)->where('is_del', 0)->paginate(10)->appends($request->except('page'));
+        $goodsList = Goods::query()->where('status', 1)->where('is_del', 0)->paginate(10)->appends($request->except('page'));
+        foreach ($goodsList as $goods) {
+            $goods->price = $goods->price / 100;
+        }
+
+        $view['goodsList'] = $goodsList;
 
         return Response::view('user/goodsList', $view);
     }
@@ -273,6 +278,7 @@ class UserController extends BaseController
                 foreach ($order->goodsList as &$goods) {
                     $g = Goods::query()->where('id', $goods->goods_id)->first();
                     $goods->goods_name = empty($g) ? '【该商品已删除】' : $g->name;
+                    $goods->price = $goods->price / 100;
                 }
             }
         }
@@ -679,7 +685,7 @@ class UserController extends BaseController
 
         $data = [
             'type'     => $coupon->type,
-            'amount'   => $coupon->amount,
+            'amount'   => $coupon->amount / 100,
             'discount' => $coupon->discount
         ];
 
@@ -758,8 +764,8 @@ class UserController extends BaseController
                 $userBalanceLogObj->user_id = $user->id;
                 $userBalanceLogObj->order_id = $order->oid;
                 $userBalanceLogObj->before = $user->balance;
-                $userBalanceLogObj->after = $user->balance - $totalPrice * 100;
-                $userBalanceLogObj->amount = $totalPrice * 100;
+                $userBalanceLogObj->after = $user->balance - $totalPrice;
+                $userBalanceLogObj->amount = -1 * $totalPrice;
                 $userBalanceLogObj->desc = '购买流量包';
                 $userBalanceLogObj->created_at = date('Y-m-d H:i:s');
                 $userBalanceLogObj->save();
@@ -813,6 +819,7 @@ class UserController extends BaseController
                 return Redirect::to('user/goodsList');
             }
 
+            $goods->price = $goods->price / 100;
             $view['goods'] = $goods;
 
             return Response::view('user/addOrder', $view);
@@ -871,11 +878,19 @@ class UserController extends BaseController
         $view['referral_traffic'] = $this->flowAutoShow(self::$config['referral_traffic'] * 1048576);
         $view['referral_percent'] = self::$config['referral_percent'];
         $view['referral_money'] = self::$config['referral_money'];
-        $view['referralLogList'] = ReferralLog::query()->where('ref_user_id', $user['id'])->with('user')->paginate();
-        $view['totalAmount'] = ReferralLog::query()->where('ref_user_id', $user['id'])->sum('ref_amount');
-        $view['canAmount'] = ReferralLog::query()->where('ref_user_id', $user['id'])->where('status', 0)->sum('ref_amount');
+        $view['totalAmount'] = ReferralLog::query()->where('ref_user_id', $user['id'])->sum('ref_amount') / 100;
+        $view['canAmount'] = ReferralLog::query()->where('ref_user_id', $user['id'])->where('status', 0)->sum('ref_amount') / 100;
         $view['link'] = self::$config['website_url'] . '/register?aff=' . $user['id'];
 
+        $referralLogList = ReferralLog::query()->where('ref_user_id', $user['id'])->with('user')->paginate(10);
+        if (!empty($referralLogList)) {
+            foreach ($referralLogList as &$referral) {
+                $referral->amount = $referral->amount / 100;
+                $referral->ref_amount = $referral->ref_amount / 100;
+            }
+        }
+        $view['referralLogList'] = $referralLogList;
+
         return Response::view('user/referral', $view);
     }
 
@@ -892,7 +907,7 @@ class UserController extends BaseController
 
         // 校验可以提现金额是否超过系统设置的阀值
         $ref_amount = ReferralLog::query()->where('ref_user_id', $user['id'])->where('status', 0)->sum('ref_amount');
-        if ($ref_amount < self::$config['referral_money']) {
+        if ($ref_amount / 100 < self::$config['referral_money']) {
             return Response::json(['status' => 'fail', 'data' => '', 'message' => '申请失败:满' . self::$config['referral_money'] . '元才可以提现,继续努力吧']);
         }
 

+ 1 - 1
resources/views/admin/applyDetail.blade.php

@@ -89,7 +89,7 @@
                         </div>
                         <div class="row">
                             <div class="col-md-4 col-sm-4">
-                                <div class="dataTables_info" role="status" aria-live="polite">共 {{$list->total()}} 个申请</div>
+                                <div class="dataTables_info" role="status" aria-live="polite">本申请共涉及 {{$list->total()}} 单</div>
                             </div>
                             <div class="col-md-8 col-sm-8">
                                 <div class="dataTables_paginate paging_bootstrap_full_number pull-right">

+ 21 - 6
resources/views/admin/layouts.blade.php

@@ -111,12 +111,6 @@
                         <span class="selected"></span>
                     </a>
                 </li>
-                <li class="nav-item start {{in_array(Request::getRequestUri(), ['/admin/userList', '/admin/addUser']) ? 'active open' : ''}}">
-                    <a href="{{url('admin/userList')}}" class="nav-link nav-toggle">
-                        <i class="icon-users"></i>
-                        <span class="title">账号管理</span>
-                    </a>
-                </li>
                 <li class="nav-item {{Request::getRequestUri() == '/admin/inviteList' ? 'active open' : ''}}">
                     <a href="{{url('admin/inviteList')}}" class="nav-link nav-toggle">
                         <i class="icon-puzzle"></i>
@@ -168,6 +162,27 @@
                         </li>
                     </ul>
                 </li>
+                <li class="nav-item {{in_array(Request::getRequestUri(), ['/admin/userList', '/admin/addUser', '/admin/editUser', '/admin/userBalanceLogList']) ? 'active open' : ''}}">
+                    <a href="javascript:;" class="nav-link nav-toggle">
+                        <i class="icon-users"></i>
+                        <span class="title">账号管理</span>
+                        <span class="arrow"></span>
+                    </a>
+                    <ul class="sub-menu">
+                        <li class="nav-item {{in_array(Request::getRequestUri(), ['/admin/userList', '/admin/addUser', '/admin/editUser']) ? 'active open' : ''}}">
+                            <a href="{{url('admin/userList')}}" class="nav-link ">
+                                <i class="icon-user"></i>
+                                <span class="title">账号列表</span>
+                            </a>
+                        </li>
+                        <li class="nav-item {{Request::getRequestUri() == '/admin/userBalanceLogList' ? 'active open' : ''}}">
+                            <a href="{{url('admin/userBalanceLogList')}}" class="nav-link ">
+                                <i class="icon-credit-card"></i>
+                                <span class="title">余额变动日志</span>
+                            </a>
+                        </li>
+                    </ul>
+                </li>
                 <li class="nav-item {{in_array(Request::getRequestUri(), ['/admin/nodeList', '/admin/addNode', '/admin/editNode', '/admin/groupList', '/admin/addGroup', '/admin/editGroup']) ? 'active open' : ''}}">
                     <a href="javascript:;" class="nav-link nav-toggle">
                         <i class="icon-layers"></i>

+ 112 - 0
resources/views/admin/userBalanceLogList.blade.php

@@ -0,0 +1,112 @@
+@extends('admin.layouts')
+
+@section('css')
+    <link href="/assets/global/plugins/datatables/datatables.min.css" rel="stylesheet" type="text/css" />
+    <link href="/assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css" rel="stylesheet" type="text/css" />
+@endsection
+@section('title', '控制面板')
+@section('content')
+    <!-- BEGIN CONTENT BODY -->
+    <div class="page-content">
+        <!-- BEGIN PAGE BREADCRUMB -->
+        <ul class="page-breadcrumb breadcrumb">
+            <li>
+                <a href="{{url('admin')}}">账号管理</a>
+                <i class="fa fa-circle"></i>
+            </li>
+            <li>
+                <a href="{{url('admin/userBalanceLogList')}}">余额变动日志</a>
+            </li>
+        </ul>
+        <!-- END PAGE BREADCRUMB -->
+        <!-- BEGIN PAGE BASE CONTENT -->
+        <div class="row">
+            <div class="col-md-12">
+                <!-- BEGIN EXAMPLE TABLE PORTLET-->
+                <div class="portlet light bordered">
+                    <div class="portlet-title">
+                        <div class="caption font-dark">
+                            <i class="icon-speedometer font-dark"></i>
+                            <span class="caption-subject bold uppercase"> 余额变动日志</span>
+                        </div>
+                    </div>
+                    <div class="portlet-body">
+                        <div class="row">
+                            <div class="col-md-2 col-sm-2">
+                                <input type="text" class="col-md-4 form-control input-sm" name="username" value="{{Request::get('username')}}" id="username" placeholder="用户名" onkeydown="if(event.keyCode==13){do_search();}">
+                            </div>
+                            <div class="col-md-2 col-sm-2">
+                                <button type="button" class="btn btn-sm blue" onclick="do_search();">查询</button>
+                                <button type="button" class="btn btn-sm grey" onclick="do_reset();">重置</button>
+                            </div>
+                        </div>
+                        <div class="table-scrollable">
+                            <table class="table table-striped table-bordered table-hover table-checkable order-column">
+                                <thead>
+                                <tr>
+                                    <th> ID </th>
+                                    <th> 用户 </th>
+                                    <th> 订单ID </th>
+                                    <th> 操作前余额 </th>
+                                    <th> 发生金额 </th>
+                                    <th> 操作后金额 </th>
+                                    <th> 描述 </th>
+                                    <th> 操作时间 </th>
+                                </tr>
+                                </thead>
+                                <tbody>
+                                    @if($list->isEmpty())
+                                        <tr>
+                                            <td colspan="8">暂无数据</td>
+                                        </tr>
+                                    @else
+                                        @foreach($list as $vo)
+                                            <tr class="odd gradeX">
+                                                <td> {{$vo->id}} </td>
+                                                <td> {{empty($vo->user) ? '【用户已删除】' : $vo->user->username}} </td>
+                                                <td> {{$vo->order_id}} </td>
+                                                <td> {{$vo->before}} </td>
+                                                <td> {{$vo->amount}} </td>
+                                                <td> {{$vo->after}} </td>
+                                                <td> {{$vo->desc}} </td>
+                                                <td> {{$vo->created_at}} </td>
+                                            </tr>
+                                        @endforeach
+                                    @endif
+                                </tbody>
+                            </table>
+                        </div>
+                        <div class="row">
+                            <div class="col-md-4 col-sm-4">
+                                <div class="dataTables_info" role="status" aria-live="polite">共 {{$list->total()}} 条记录</div>
+                            </div>
+                            <div class="col-md-8 col-sm-8">
+                                <div class="dataTables_paginate paging_bootstrap_full_number pull-right">
+                                    {{ $list->links() }}
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <!-- END EXAMPLE TABLE PORTLET-->
+            </div>
+        </div>
+        <!-- END PAGE BASE CONTENT -->
+    </div>
+    <!-- END CONTENT BODY -->
+@endsection
+@section('script')
+    <script type="text/javascript">
+        // 搜索
+        function do_search() {
+            var username = $("#username").val();
+
+            window.location.href = '{{url('admin/userBalanceLogList')}}' + '?username=' + username;
+        }
+
+        // 重置
+        function do_reset() {
+            window.location.href = '{{url('admin/userBalanceLogList')}}';
+        }
+    </script>
+@endsection

+ 1 - 1
resources/views/user/addOrder.blade.php

@@ -36,7 +36,7 @@
                         <tr>
                             <td style="padding: 10px;">
                                 <h2>{{$goods->name}}</h2>
-                                <p> 内含流量 {{$goods->traffic}} MiB <br> 有效期 {{$goods->days}}天,到期后自动扣除 </p>
+                                <p> 内含流量 {{$goods->traffic}} MiB <br> 有效期 {{$goods->days}}天 </p>
                             </td>
                             <td class="text-center"> ¥{{$goods->price}} </td>
                             <td class="text-center"> x 1 </td>

+ 1 - 0
routes/web.php

@@ -64,6 +64,7 @@ Route::group(['middleware' => ['user', 'admin']], function() {
     Route::post('admin/setQrcode', 'AdminController@setQrcode'); // 设置充值二维码
     Route::post('admin/resetUserTraffic', 'AdminController@resetUserTraffic'); // 重置用户流量
     Route::post('admin/handleUserBalance', 'AdminController@handleUserBalance'); // 余额充值
+    Route::get('admin/userBalanceLogList', 'AdminController@userBalanceLogList'); // 余额变动日志
     Route::get('admin/makePasswd', 'AdminController@makePasswd'); // 获取随机密码
     Route::get('admin/download', 'AdminController@download'); // 下载转换过的JSON配置
     Route::any('shop/goodsList', 'ShopController@goodsList'); // 商品列表

+ 14 - 16
sql/db.sql

@@ -64,9 +64,8 @@ CREATE TABLE `ss_node_info` (
   `uptime` float NOT NULL COMMENT '更新时间',
   `load` varchar(32) NOT NULL COMMENT '负载',
   `log_time` int(11) NOT NULL COMMENT '记录时间',
-  `created_at` datetime NOT NULL,
-  `updated_at` datetime NOT NULL,
-  PRIMARY KEY (`id`)
+  PRIMARY KEY (`id`),
+  KEY `idx_node_id` (`node_id`) USING BTREE
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='节点负载信息';
 
 
@@ -110,7 +109,7 @@ CREATE TABLE `user` (
   `qq` varchar(20) DEFAULT '' COMMENT 'QQ',
   `usage` tinyint(4) NOT NULL DEFAULT '4' COMMENT '用途:1-手机、2-电脑、3-路由器、4-其他',
   `pay_way` tinyint(4) NOT NULL DEFAULT '0' COMMENT '付费方式:0-免费、1-月付、2-半年付、3-年付',
-  `balance` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '余额',
+  `balance` int(11) NOT NULL DEFAULT '0' COMMENT '余额,单位分',
   `score` int(11) NOT NULL DEFAULT '0' COMMENT '积分',
   `enable_time` date DEFAULT NULL COMMENT '开通日期',
   `expire_time` date NOT NULL DEFAULT '2099-01-01' COMMENT '过期时间',
@@ -119,7 +118,7 @@ CREATE TABLE `user` (
   `level` tinyint(4) NOT NULL DEFAULT '1' COMMENT '等级:可定义名称',
   `is_admin` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否管理员:0-否、1-是',
   `reg_ip` varchar(20) NOT NULL DEFAULT '127.0.0.1' COMMENT '注册IP',
-  `last_login` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次登录时间',
+  `last_login` int(11) NOT NULL DEFAULT '0' COMMENT '最后登录时间',
   `referral_uid` int(11) NOT NULL DEFAULT '0' COMMENT '邀请人',
   `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态:-1-禁用、0-未激活、1-正常',
   `created_at` datetime DEFAULT NULL,
@@ -404,7 +403,6 @@ CREATE TABLE `goods` (
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商品信息表';
 
 
-
 -- ----------------------------
 -- Table structure for `coupon`
 -- ----------------------------
@@ -449,13 +447,13 @@ CREATE TABLE `order` (
   `orderId` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单编号',
   `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '操作人',
   `coupon_id` int(11) NOT NULL DEFAULT '0' COMMENT '优惠券ID',
-  `totalOriginalPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '订单原始总价',
-  `totalPrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '订单总价',
+  `totalOriginalPrice` int(11) NOT NULL DEFAULT '0' COMMENT '订单原始总价,单位分',
+  `totalPrice` int(11) NOT NULL DEFAULT '0' COMMENT '订单总价,单位分',
   `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '订单状态:-1-已关闭、0-待支付、1-已支付待确认、2-已完成',
   `created_at` datetime DEFAULT NULL COMMENT '创建时间',
   `updated_at` datetime DEFAULT NULL COMMENT '最后更新时间',
   PRIMARY KEY (`oid`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='订单信息表';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='订单信息表';
 
 
 -- ----------------------------
@@ -468,8 +466,8 @@ CREATE TABLE `order_goods` (
   `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
   `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '商品ID',
   `num` int(11) NOT NULL DEFAULT '0' COMMENT '商品数量',
-  `original_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品原价',
-  `price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '商品实际价格',
+  `original_price` int(11) NOT NULL DEFAULT '0' COMMENT '商品原价,单位分',
+  `price` int(11) NOT NULL DEFAULT '0' COMMENT '商品实际价格,单位分',
   `is_expire` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否已过期:0-未过期、1-已过期',
   `created_at` datetime DEFAULT NULL COMMENT '创建时间',
   `updated_at` datetime DEFAULT NULL COMMENT '最后更新时间',
@@ -542,9 +540,9 @@ CREATE TABLE `user_balance_log` (
 CREATE TABLE `referral_apply` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
-  `before` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '操作前可提现金额',
-  `after` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '操作后可提现金额',
-  `amount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '本次提现金额',
+  `before` int(11) NOT NULL DEFAULT '0' COMMENT '操作前可提现金额,单位分',
+  `after` int(11) NOT NULL DEFAULT '0' COMMENT '操作后可提现金额,单位分',
+  `amount` int(11) NOT NULL DEFAULT '0' COMMENT '本次提现金额,单位分',
   `link_logs` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '关联返利日志ID,例如:1,3,4',
   `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态:-1-驳回、0-待审核、1-审核通过待打款、2-已打款',
   `created_at` datetime DEFAULT NULL COMMENT '创建时间',
@@ -561,13 +559,13 @@ CREATE TABLE `referral_log` (
   `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
   `ref_user_id` int(11) NOT NULL DEFAULT '0' COMMENT '推广人ID',
   `order_id` int(11) NOT NULL DEFAULT '0' COMMENT '关联订单ID',
-  `amount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '消费金额',
+  `amount` int(11) NOT NULL DEFAULT '0' COMMENT '消费金额,单位分',
   `ref_amount` int(11) NOT NULL DEFAULT '0' COMMENT '返利金额',
   `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态:0-未提现、1-审核中、2-已提现',
   `created_at` datetime DEFAULT NULL COMMENT '创建时间',
   `updated_at` datetime DEFAULT NULL COMMENT '最后更新时间',
   PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='消费返利日志';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='消费返利日志';
 
 
 -- ----------------------------

+ 27 - 0
sql/update/20171201.sql

@@ -0,0 +1,27 @@
+-- 消费返利日志表字段类型调整
+ALTER TABLE `referral_log` MODIFY `amount` int(11) NOT NULL DEFAULT '0' COMMENT '消费金额,单位分';
+UPDATE `referral_log` SET amount = amount * 100;
+
+-- 消费提现申请表字段类型调整
+ALTER TABLE `referral_apply` MODIFY `before` int(11) NOT NULL DEFAULT '0' COMMENT '操作前可提现金额,单位分';
+UPDATE `referral_apply` SET before = before * 100;
+
+ALTER TABLE `referral_apply` MODIFY `after` int(11) NOT NULL DEFAULT '0' COMMENT '操作后可提现金额,单位分';
+UPDATE `referral_apply` SET after = after * 100;
+
+ALTER TABLE `referral_apply` MODIFY `amount` int(11) NOT NULL DEFAULT '0' COMMENT '本次提现金额,单位分';
+UPDATE `referral_apply` SET amount = amount * 100;
+
+-- 订单商品表字段类型调整
+ALTER TABLE `order_goods` MODIFY `original_price` int(11) NOT NULL DEFAULT '0' COMMENT '商品原价,单位分';
+UPDATE `order_goods` SET original_price = original_price * 100;
+
+ALTER TABLE `order_goods` MODIFY `price` int(11) NOT NULL DEFAULT '0' COMMENT '商品实际价格,单位分';
+UPDATE `order_goods` SET price = price * 100;
+
+-- 订单表字段类型调整
+ALTER TABLE `order` MODIFY `totalOriginalPrice` int(11) NOT NULL DEFAULT '0' COMMENT '订单原始总价,单位分';
+UPDATE `order` SET totalOriginalPrice = totalOriginalPrice * 100;
+
+ALTER TABLE `order` MODIFY `totalPrice` int(11) NOT NULL DEFAULT '0' COMMENT '订单总价,单位分';
+UPDATE `order` SET totalPrice = totalPrice * 100;