Kirin 3 éve
szülő
commit
7aff0bae7a

+ 2 - 2
app/api/controller/mining/MiningController.php

@@ -74,7 +74,7 @@ class MiningController
 
     public function mining_index(Request $request)
     {
-        $type = $request->get('type','XCH');
+        $type = $request->get('type', 'XCH');
         $all = UserMiningMachine::where('get_money_type', 'in', $type)->where('uid', $request->uid())->sum('num');
         $doing = UserMiningMachine::where('get_money_type', 'in', $type)->where('uid', $request->uid())->where('status', 'in', [1, 2])->sum('num');
         $stand = UserMiningMachine::where('get_money_type', 'in', $type)->where('uid', $request->uid())->where('status', 0)->sum('num');
@@ -95,7 +95,7 @@ class MiningController
         $limit = $request->get('limit', 10);
         $get_money_type = $request->get('get_money_type', '');
         $type = $request->get('type', '');
-        return app('json')->success('ok', MiningMachine::getList($page, $limit, ['get_money_type' => $get_money_type, 'type' => $type]));
+        return app('json')->success('ok', MiningMachine::getList($page, $limit, ['get_money_type' => $get_money_type, 'type' => $type, 'uid' => $request->uid()]));
     }
 
     /**

+ 7 - 1
app/models/mining/MiningMachine.php

@@ -47,11 +47,17 @@ class MiningMachine extends BaseModel
         if (isset($where['get_money_type']) && $where['get_money_type'] != '') $model = $model->where('get_money_type', $where['get_money_type']);
         if (isset($where['type']) && $where['type'] != '') $model = $model->where('type', $where['type']);
         $count = $model->count();
-        $data = $model->order('id', 'desc')->page($page, $limit)->select()->each(function ($item) use ($money_type) {
+        $data = $model->order('id', 'desc')->page($page, $limit)->select()->each(function ($item) use ($money_type, $where) {
             $item['_day_get'] = $item['day_get'] . $money_type[$item['get_money_type']] . '/T';
             $item['_cost_money'] = $item['cost_money'] . $money_type[$item['cost_money_type']];
             $item['_stand_money'] = $item['stand_money'] . $money_type[$item['get_money_type']];
             $item['tags'] = explode(',', $item['tags']);
+            $item['award_ratio'] = 0;
+            //$item['service'] = explode(',', $item['tags']);
+            if (isset($where['uid']) && $where['uid']) {
+                $item['award_ratio'] = UserMiningRatio::where('uid', $where['uid'])->where('mid', $item['id'])->value('ratio');
+                $item['service_ratio'] = UserMiningService::where('uid', $where['uid'])->where('mid', $item['id'])->value('ratio') ?: $item['service_ratio'];
+            }
         })->toArray();
         return compact('count', 'data');
     }