hrjy před 3 roky
rodič
revize
bd555914e1

+ 5 - 0
app/admin/model/user/User.php

@@ -6,6 +6,7 @@
 
 namespace app\admin\model\user;
 
+use app\admin\model\auction\AuctionGu;
 use app\admin\model\order\StoreOrder;
 use app\admin\model\system\SystemUserLevel;
 use crmeb\traits\ModelTrait;
@@ -204,6 +205,10 @@ class User extends BaseModel
                     if ($levelinfo['is_forever']) $item['vip_name'] = SystemUserLevel::where('id', $levelinfo['level_id'])->value('name');
                     else if (time() > $levelinfo['valid_time']) $item['vip_name'] = SystemUserLevel::where('id', $levelinfo['level_id'])->value('name');
                 }
+                $auction  = AuctionGu::where('uid', $item['uid'])->find();
+                if ($auction){
+                    $item['vip_name'] = '馆长';
+                }
             });//->toArray();
         $count = self::setWherePage(self::setWhere($where), $where, ['w.sex', 'w.province', 'w.city', 'u.status', 'u.is_promoter'], ['u.nickname', 'u.uid'])->alias('u')->join('WechatUser w', 'u.uid=w.uid')->count();
         return ['count' => $count, 'data' => $list];

+ 1 - 1
app/admin/view/user/user/index.php

@@ -216,7 +216,7 @@
                     <script type="text/html" id="nickname">
                         {{d.nickname}}
                         {{# if(d.vip_name){ }}
-                        <p style="color:#dab176">{{d.vip_name}}</p>
+<!--                        <p style="color:#dab176">{{d.vip_name}}</p>-->
                         {{# } }}
                     </script>
                     <script type="text/html" id="data_time">

+ 15 - 12
app/api/controller/auction/AuctionController.php

@@ -74,7 +74,7 @@ class AuctionController
 
         $userModel = new User();
         $user = $userModel->find($request->uid());
-
+        if ($user['is_auth'] != 2) return app('json')->fail('未实名认证');
         if ($user['anticipate'] < $auction['anticipate']) return app('json')->fail('预约卷不够');
         $user['anticipate'] = $user['anticipate'] - $auction['anticipate'];// 扣除预约卷
 
@@ -108,7 +108,7 @@ class AuctionController
         if (!$data['id']) return app('json')->fail('数据传入错误');
         $auction = Auction::find($data['id']);
         $booking = AuctionBooking::where([['auction_id', '=',$auction['id']], ['frequency', '=', $auction['frequency']]])->find();
-        $radd_time = strtotime($auction['radd_time']) - 360; // 提前分钟进场
+        $radd_time = strtotime($auction['radd_time']) - 360; // 提前6分钟进场
 
         if (!$booking){
             return app('json')->fail('未预约');
@@ -174,19 +174,26 @@ class AuctionController
     public function transfer_accounts(Request $request){
         $data = UtilService::getMore([
             ['uid'],
-            ['anticipate']
+            ['anticipate'],
+            ['payment']
         ], $request);
         if (!$data['uid'] or !$data['anticipate'])  return app('json')->fail('数据传入错误');
+        if (!$data['payment']) return app('json')->fail('请填写支付密码');
         $user = User::find($request->uid());
-        if ($user['anticipate'] < $data['anticipate']) return app('json')->fail('预约卷不够');
+        $userList = User::select();
+        $uid = get_downline($userList, $user['uid']);
+
+        if ($user['payment'] != md5($data['payment'])) return app('json')->fail('支付密码错误');
+        if (!in_array($data['uid'],$uid)) return app('json')->fail('该用户不是你下级');
+        if ($data['anticipate'] < 10) return app('json')->fail('最少转账10');
+        if ($user['anticipate'] < $data['anticipate']) return app('json')->fail('艺金券不够');
         $me = User::find($data['uid']);
         $user['anticipate'] = $user['anticipate'] - $data['anticipate'];// 扣除预约卷
         $me['anticipate'] = $me['anticipate'] + $data['anticipate'];// 增加预约卷
-
         try {
             Db::startTrans();
-            UserBill::expend('预约卷减少',$user['uid'], 'anticipate', 'reduce_anticipate', $data['anticipate'], 0, $user['anticipate'], '转账给用户'.$me['nickname'].$data['anticipate'].'预约卷');
-            UserBill::income('预约卷增加',$me['uid'], 'anticipate', 'add_anticipate', $data['anticipate'], 0, $me['anticipate'], $me['nickname'].'转账'.$data['anticipate'].'预约卷');
+            UserBill::expend('艺金券减少',$user['uid'], 'anticipate', 'reduce_anticipate', $data['anticipate'], 0, $user['anticipate'], '转账给('.$me['nickname'].')'.$data['anticipate'].'预约卷');
+            UserBill::income('艺金券增加',$me['uid'], 'anticipate', 'add_anticipate', $data['anticipate'], 0, $me['anticipate'], '接收('.$user['nickname'].'-'.$user['uid'].')转账'.$data['anticipate'].'预约卷');
             $user->save();
             $me->save();
 
@@ -440,11 +447,7 @@ class AuctionController
         $time = strtotime(date('Y-m-d', time()));// 今天
         $today = strtotime(date('Y-m-d', strtotime('+1day')));// 明天
         $datas = [];
-        if ($user['is_new'] == 1 or ($user['green_time'] >= $time and $user['green_time'] <= $today)){
-            $datas['time'] = strtotime($list['radd_time']) - 180;
-        }else{
-            $datas['time'] = strtotime($list['radd_time']);
-        }
+        $datas['time'] = strtotime($list['radd_time']);
 
         return app('json')->success($datas);// 失败
     }

+ 60 - 0
app/api/controller/user/UserController.php

@@ -23,6 +23,7 @@ use app\models\user\UserNotice;
 use crmeb\services\GroupDataService;
 use crmeb\services\UtilService;
 use app\http\validates\user\UserValidates as Userva;
+
 /**
  * 用户类
  * Class UserController
@@ -642,4 +643,63 @@ class UserController
 
     }
 
+    /**
+     * 是否已设置支付密码
+     * @param Request $request
+     * @return mixed
+     */
+    public function is_pas(Request $request)
+    {
+        $user = $request->user();
+        if ($user['payment']){
+            return app('json')->success(['status' => 1]);
+        }else{
+            return app('json')->success(['status' => 0]);
+        }
+    }
+
+    /**
+     * 设置支付密码
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function set_payment(Request $request)
+    {
+        $data = UtilService::postMore([
+            ['type'],
+            ['payment'],
+            ['old_payment']
+        ], $request);
+        if (!$data['type']) return app('json')->fail('类型不能为空');
+        if (!$data['payment']) return app('json')->fail('密码不能为空');
+        if (strlen($data['payment']) != 6) return app('json')->fail('密码必须为六位');
+        $validate = new \think\Validate();
+        $validate->rule('payment' , 'number');
+        $validate->message(['payment.number' => '密码必须为数字']);
+        if (!$validate->check($data)) return app('json')->fail($validate->getError());
+
+        $user = User::where('uid', $request->uid())->find();
+        if ($data['type'] == 1){
+            $user['payment'] = md5($data['payment']);
+            $res = $user->save();
+            if ($res){
+                return app('json')->success('成功');
+            }else{
+                return app('json')->fail('失败');
+            }
+        }elseif ($data['type'] == 2){
+            if (md5($data['old_payment']) != $user['payment']) return app('json')->fail('旧密码错误');
+            $user['payment'] = md5($data['payment']);
+            if ($user->save()){
+                return app('json')->success('成功');
+            }else{
+                return app('json')->fail('失败');
+            }
+        }
+        return app('json')->fail('错误');
+    }
+
 }

+ 17 - 0
app/common.php

@@ -555,5 +555,22 @@ if (!function_exists('today')) {
 
         return $today;
 
+    }
+}
+
+if (!function_exists('get_downline')){
+    //所有下级
+    function get_downline($members,$id){
+        $arr=array();
+        foreach ($members as $key => $v) {
+
+            if($v['spread_uid']==$id){  //pid为0的是顶级分类
+
+                $arr[]=$v['uid'];
+                $arr = array_merge($arr,get_downline($members,$v['uid']));
+            }
+        }
+        return $arr;
+
     }
 }

+ 11 - 0
app/models/user/User.php

@@ -686,4 +686,15 @@ class User extends BaseModel
         }
         return $model->where('brokerage_price', '>', $brokerage_price)->count('uid');
     }
+
+    /**
+     * 获取ID
+     * @param $key
+     * @return mixed
+     */
+    public static function getkeytoid($key)
+    {
+        $rs = self::order('uid DESC')->find();
+        return $rs['uid']+1;
+    }
 }

+ 3 - 0
route/api/route.php

@@ -197,6 +197,9 @@ Route::group(function () {
     Route::post('auction/plead', 'auction.auctionOrderController/plead')->name('plead');// 申诉
     Route::post('auction/revoke', 'auction.auctionOrderController/revoke')->name('revoke');// 撤销申诉
 
+    Route::get('is_pas', 'user.UserController/is_pas')->name('is_pas');// 是否设定支付密码
+    Route::post('set_payment', 'user.UserController/set_payment')->name('set_payment');// 支付密码
+
 })->middleware(\app\http\middleware\AllowOriginMiddleware::class)->middleware(\app\http\middleware\AuthTokenMiddleware::class, true);
 //未授权接口
 Route::group(function () {