Kirin 4 년 전
부모
커밋
19b07d165a

+ 1 - 1
app/admin/controller/user/UserLevel.php

@@ -42,7 +42,7 @@ class UserLevel extends AuthController
         $field[] = Form::number('layer_award_layer', '团队奖层数', isset($vipinfo) ? $vipinfo->layer_award_layer : 0)->min(0)->col(8);
         $field[] = Form::number('layer_award_ratio', '团队奖百分比', isset($vipinfo) ? $vipinfo->layer_award_ratio : 0)->min(0)->col(8);
         $field[] = Form::number('recommend_award_ratio', '直推奖比例', isset($vipinfo) ? $vipinfo->recommend_award_ratio : 0)->min(0)->col(8);
-        $field[] = Form::number('group_creat_award_ratio', '团队产币分红', isset($vipinfo) ? $vipinfo->group_creat_award_ratio : 0)->min(0)->col(8);
+//        $field[] = Form::number('group_creat_award_ratio', '团队产币分红', isset($vipinfo) ? $vipinfo->group_creat_award_ratio : 0)->min(0)->col(8);
         $field[] = Form::radio('system_create_award_ratio', '平台产币分红', isset($vipinfo) ? $vipinfo->system_create_award_ratio : 0)->options([['label' => '有', 'value' => 1], ['label' => '无', 'value' => 0]])->col(8);
 //        $field[] = Form::number('discount', '享受折扣', isset($vipinfo) ? $vipinfo->discount : 0)->min(0)->col(8);
         $field[] = Form::frameImageOne('icon', '图标', Url::buildUrl('admin/widget.images/index', array('fodder' => 'icon')), isset($vipinfo) ? $vipinfo->icon : '')->icon('image')->width('100%')->height('500px');

+ 3 - 1
app/api/controller/PublicController.php

@@ -51,7 +51,9 @@ class PublicController
 
     public function test(Request $request)
     {
-        UserMiningMachine::dayMining();
+
+        var_dump(get_fil_price());
+//        UserMiningMachine::dayMining();
 //        SystemUserTask::SmallGroupHashRate(1, 1);
 //        UserMiningMachine::dayMining();
 //        $money_types = MiningMachine::group('get_money_type')->field('COUNT(id),get_money_type')->select();

+ 41 - 0
app/api/controller/user/UserBillController.php

@@ -3,7 +3,9 @@
 namespace app\api\controller\user;
 
 use app\admin\model\system\SystemAttachment;
+use app\models\mining\MiningMachine;
 use app\models\mining\UserMiningMachine;
+use app\models\mining\UserMiningRatio;
 use app\models\routine\RoutineCode;
 use app\models\routine\RoutineQrcode;
 use app\models\store\StoreOrder;
@@ -384,4 +386,43 @@ class UserBillController
         return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit));
 
     }
+
+
+    public function setReturnUper($uid, Request $request)
+    {
+        $user = User::getUserInfo($uid);
+        if (!$user || $user['spread_uid'] != $request->uid()) {
+            return app('json')->fail('用户不合法');
+        }
+        $ratio = $request->post('ratio', 0);
+        $mid = $request->post('mid', 0);
+        if (!$mid || !MiningMachine::get($mid)) return app('json')->fail('矿机不合法');
+        $self = UserMiningRatio::where('mid', $mid)->where('uid', $request->uid())->find();
+        if ($ratio > $self['ratio']) {
+            return app('json')->fail('佣金比例不能超过自己');
+        }
+        $uids = User::where('spread_uid', $user['uid'])->column('uid');
+        $user2 = UserMiningRatio::where('mid', $mid)->where('uid', 'in', $uids)->max('ratio');
+        if ($ratio < $user2) {
+            return app('json')->fail('佣金比例不能低于目标下级');
+        }
+        if (UserMiningRatio::where('mid', $mid)->where('uid', $uid)->find()) {
+            $res = UserMiningRatio::where('mid', $mid)->where('uid', $uid)
+                ->update(['ratio' => $ratio, 'update_time' => time(), 'update_uid' => $request->uid()]);
+        } else {
+            $res = UserMiningRatio::create([
+                'uid' => $uid,
+                'mid' => $mid,
+                'ratio' => $ratio,
+                'add_time' => time(),
+                'update_time' => time(),
+                'update_uid' => $request->uid(),
+            ]);
+        }
+        if ($res) {
+            return app('json')->success('修改成功');
+        } else {
+            return app('json')->fail('修改失败或者您没有修改什么');
+        }
+    }
 }

+ 26 - 0
app/common.php

@@ -667,3 +667,29 @@ if (!function_exists('get_hpool_price')) {
         return $price;
     }
 }
+
+if (!function_exists('get_fil_price')) {
+    /**
+     * @param $unit
+     * @return float
+     */
+    function get_fil_price(): float
+    {
+        $res = do_request('https://filfox.info/api/v1/overview', [], null, false);
+        $res = json_decode($res, true);
+        $price = 0;
+        if (!isset($res['code']) || $res['code'] != 200) $price = 0;
+//        foreach ($res['data'] as $v) {
+//            if ($v['unit'] == $unit) {
+//                $price = bcdiv($v['income'], 1024, 8);
+//                break;
+//            }
+//        }
+        $coins = $res['dailyCoinsMined'];
+        $power = $res['totalQualityAdjPower'];
+        $coins = bcdiv($coins, '1000000000000000000', 8);
+        $power = bcdiv($power, bcpow(1024, 5), 8);
+        $price = bcdiv($coins, $power, 8);
+        return $price;
+    }
+}

+ 15 - 6
app/models/mining/UserMiningMachine.php

@@ -74,7 +74,14 @@ class UserMiningMachine extends BaseModel
                 $money_types = MiningMachine::group('get_money_type')->field('COUNT(id),get_money_type')->select();
                 $day_gets = [];
                 foreach ($money_types as $v) {
-                    $day_gets[$v['get_money_type']] = get_hpool_price($v['get_money_type']);
+
+                    if ($v['get_money_type'] == 'XCH') {
+                        $day_gets[$v['get_money_type']] = get_hpool_price($v['get_money_type']);
+                    } else if ($v['get_money_type'] == 'FIL') {
+                        $day_gets[$v['get_money_type']] = get_fil_price();
+                    } else {
+                        $day_gets[$v['get_money_type']] = get_hpool_price($v['get_money_type']);
+                    }
                 }
                 foreach ($list as $v) {
                     $machine = MiningMachine::get($v['mid']);
@@ -105,7 +112,7 @@ class UserMiningMachine extends BaseModel
                         }
                         if ($day_unlock > 0) {
                             $res = $res && UserMoney::incomeMoney($v['uid'], $v['get_money_type'], $day_unlock, 'mining', '挖矿', '第二阶段锁定金释放' . $day_unlock . init_money_type()[$v['get_money_type']])
-                                && self::sendGroupAward($v['uid'], $v['get_money_type'], $day_unlock)
+                                && self::sendGroupAward($v['uid'], $v['mid'], $v['get_money_type'], $day_unlock)
                                 && self::sendSystemAward($v['uid'], $v['get_money_type'], $day_unlock);
                         }
                         if ($send_stand > 0) {
@@ -140,7 +147,7 @@ class UserMiningMachine extends BaseModel
                                     'lock_money' => $day_lock,
                                     'day_unlock_money' => bcdiv($day_lock, $machine['third_step_time'], 8),
                                 ]) && UserMoney::incomeMoney($v['uid'], $v['get_money_type'], bcadd($day_real_get, $day_unlock, 8), 'mining', '挖矿', '第二阶段每日释放' . $day_get . init_money_type()[$v['get_money_type']] . ',扣除技术服务费后实际到账' . $day_real_get . init_money_type()[$v['get_money_type']] . ($day_lock > 0 ? ',锁定' . $day_lock . init_money_type()[$v['get_money_type']] : '') . ($day_unlock > 0 ? ',解锁第二阶段锁定金' . $day_unlock . init_money_type()[$v['get_money_type']] : ''))
-                                && self::sendGroupAward($v['uid'], $v['get_money_type'], bcadd($day_real_get, $day_unlock, 8))
+                                && self::sendGroupAward($v['uid'], $v['mid'], $v['get_money_type'], bcadd($day_real_get, $day_unlock, 8))
                                 && self::sendSystemAward($v['uid'], $v['get_money_type'], bcadd($day_real_get, $day_unlock, 8));
                         }
                     } else {
@@ -163,7 +170,7 @@ class UserMiningMachine extends BaseModel
                                     'add_time' => time(),
                                     'add_date' => date('Y-m-d'),
                                 ]) && UserMoney::incomeMoney($v['uid'], $v['get_money_type'], bcadd($day_real_get, 0, 8), 'mining', '挖矿', '第一阶段每日释放' . $day_get . init_money_type()[$v['get_money_type']] . ',扣除技术服务费后实际到账' . $day_real_get . init_money_type()[$v['get_money_type']] . ($day_stand > 0 ? ',质押' . $day_stand . init_money_type()[$v['get_money_type']] : ''))
-                                && self::sendGroupAward($v['uid'], $v['get_money_type'], bcadd($day_real_get, 0, 8))
+                                && self::sendGroupAward($v['uid'], $v['mid'], $v['get_money_type'], bcadd($day_real_get, 0, 8))
                                 && self::sendSystemAward($v['uid'], $v['get_money_type'], bcadd($day_real_get, 0, 8));
                         }
                         if ($day_stand > 0) {
@@ -183,14 +190,16 @@ class UserMiningMachine extends BaseModel
         }
     }
 
-    public static function sendGroupAward($uid, $money_type, $num)
+    public static function sendGroupAward($uid, $mid, $money_type, $num)
     {
         $user = User::getUserInfo($uid);
         $spread = User::getUserInfo($user['spread_uid']);
         $res = true;
         $send = 0;
         while ($spread) {
-            $ratio = UserLevel::getUserLevelInfo(UserLevel::getUserLevel($spread['uid']), 'group_creat_award_ratio');
+//            $ratio = UserLevel::getUserLevelInfo(UserLevel::getUserLevel($spread['uid']), 'group_creat_award_ratio');
+            $ratio = UserMiningRatio::where('uid', $uid)->where('mid', $mid)->value('ratio');
+            if (!$ratio) $ratio = 0;
             if ($ratio <= 0) {
                 $spread = User::getUserInfo($spread['spread_uid']);
             } else {

+ 5 - 0
public/.htaccess

@@ -0,0 +1,5 @@
+location / {
+	if (!-e $request_filename){
+		rewrite  ^(.*)$  /index.php?s=$1  last;   break;
+	}
+}

+ 1 - 0
route/api/route.php

@@ -193,6 +193,7 @@ Route::group(function () {
     Route::post('combination/remove', 'activity.StoreCombinationController/remove')->name('combinationRemove');//拼团 取消开团
     Route::post('combination/poster', 'activity.StoreCombinationController/poster')->name('combinationPoster');//拼团海报
     //账单类
+    Route::post('spread/ratio/:uid', 'user.UserBillController/setReturnUper')->name('setReturnUper');//设置佣金比例
     Route::get('commission', 'user.UserBillController/commission')->name('commission');//推广数据 昨天的佣金 累计提现金额 当前佣金
     Route::post('spread/people', 'user.UserBillController/spread_people')->name('spreadPeople');//推荐用户
     Route::post('spread/people/all', 'user.UserBillController/spread_people_all')->name('spreadPeople');//推荐用户