hrjy 2 years ago
parent
commit
2506fd3abf

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

@@ -358,4 +358,89 @@ class UserBillController
         return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit, 'integral', ['pm' => $status]));
 
     }
+
+    /**
+     * 白积分记录
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function white_integral(Request $request)
+    {
+        list($page, $limit, $status) = UtilService::getMore([
+            ['page', 0], ['limit', 0], ['pm', 0]
+        ], $request, true);
+        return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit, 'white_integral', ['pm' => $status]));
+
+    }
+
+    /**
+     * 紫积分记录
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function purple_integral(Request $request)
+    {
+        list($page, $limit, $status) = UtilService::getMore([
+            ['page', 0], ['limit', 0], ['pm', 0]
+        ], $request, true);
+        return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit, 'purple_integral', ['pm' => $status]));
+
+    }
+
+    /**
+     * 绿积分记录
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function green_integral(Request $request)
+    {
+        list($page, $limit, $status) = UtilService::getMore([
+            ['page', 0], ['limit', 0], ['pm', 0]
+        ], $request, true);
+        return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit, 'green_integral', ['pm' => $status]));
+
+    }
+
+    /**
+     * 商家积分记录
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function business_integral(Request $request)
+    {
+        list($page, $limit, $status) = UtilService::getMore([
+            ['page', 0], ['limit', 0], ['pm', 0]
+        ], $request, true);
+        return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit, 'business_integral', ['pm' => $status]));
+
+    }
+
+    /**
+     * 文票记录
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function paper_ticket(Request $request)
+    {
+        list($page, $limit, $status) = UtilService::getMore([
+            ['page', 0], ['limit', 0], ['pm', 0]
+        ], $request, true);
+        return app('json')->successful(UserBill::userBillList($request->uid(), $page, $limit, 'paper_ticket', ['pm' => $status]));
+
+    }
 }

+ 4 - 3
app/api/controller/user/UserExtractController.php

@@ -60,6 +60,7 @@ class UserExtractController
     public function cash(Request $request)
     {
         $extractInfo = UtilService::postMore([
+            ['type'],
             ['alipay_code', ''],
             ['extract_type', ''],
             ['money', 0],
@@ -68,7 +69,7 @@ class UserExtractController
             ['cardnum', ''],
             ['weixin', ''],
         ], $request);
-        if (time() - CacheService::get('UserExtract_' . $request->uid(), time()) < 10) return app('json')->fail('请勿连续多次提交');
+        if (time() - CacheService::get('UserExtract_' . $request->uid(), time()) < 5) return app('json')->fail('请勿连续多次提交');
         else CacheService::set('UserExtract_' . $request->uid(), time());
         if (!preg_match('/^(([1-9]\d*)|0)(\.\d{1-2})?$/', $extractInfo['money'])) return app('json')->fail('提现金额输入有误');
         $user = $request->user();
@@ -92,8 +93,8 @@ class UserExtractController
             $data['broken_commission'] = 0;
         $data['brokerage_price'] = $user['brokerage_price'];
         //可提现佣金
-        $commissionCount = $data['brokerage_price'] - $data['broken_commission'];
-        if ($extractInfo['money'] > $commissionCount) return app('json')->fail('可提现佣金不足');
+//        $commissionCount = $data['brokerage_price'] - $data['broken_commission'];
+//        if ($extractInfo['money'] > $commissionCount) return app('json')->fail('可提现佣金不足');
         if (!$extractInfo['cardnum'] == '')
             if (!preg_match('/^([1-9]{1})(\d{14}|\d{18})$/', $extractInfo['cardnum']))
                 return app('json')->fail('银行卡号输入有误');

+ 25 - 10
app/models/user/UserExtract.php

@@ -60,11 +60,26 @@ class UserExtract extends BaseModel
         if(!in_array($data['extract_type'],self::$extractType))
             return self::setErrorInfo('提现方式不存在');
         $userInfo = User::get($userInfo['uid']);
-        $extractPrice = $userInfo['brokerage_price'];
-        if($extractPrice < 0) return self::setErrorInfo('提现佣金不足'.$data['money']);
-        if($data['money'] > $extractPrice) return self::setErrorInfo('提现佣金不足'.$data['money']);
-        if($data['money'] <= 0) return self::setErrorInfo('提现佣金大于0');
-        $balance = bcsub($userInfo['brokerage_price'],$data['money'],2);
+        $sxf = 0;
+        $js = '';
+        $bl = '';
+        if ($data['type'] == 1){
+            if ($data['money'] > $userInfo['purple_integral']) return self::setErrorInfo('紫积分不足');
+            $extractPrice = $userInfo['purple_integral'];
+            $js = '紫积分';
+            $bl = 'purple_integral';
+        }elseif ($data['type'] == 2){
+            if ($data['money'] > $userInfo['business_integral']) return self::setErrorInfo('商家积分不足');
+            $extractPrice = $userInfo['business_integral'];
+            $js = '商家积分';
+            $bl = 'business_integral';
+        }
+//        $extractPrice = $userInfo['brokerage_price'];
+        if($extractPrice < 0) return self::setErrorInfo('提现积分不足'.$data['money']);
+        if($data['money'] > $extractPrice) return self::setErrorInfo('提现积分不足'.$data['money']);
+        if($data['money'] <= 0) return self::setErrorInfo('提现积分大于0');
+
+        $balance = bcsub($extractPrice,$data['money'],2);
         if($balance < 0) $balance=0;
         $insertData = [
             'uid' => $userInfo['uid'],
@@ -85,21 +100,21 @@ class UserExtract extends BaseModel
         if($data['extract_type'] == 'alipay'){
             if(!$data['alipay_code']) return self::setErrorInfo('请输入支付宝账号');
             $insertData['alipay_code'] = $data['alipay_code'];
-            $mark = '使用支付宝提现'.$insertData['extract_price'].'元';
+            $mark = '提现'.$js.',使用支付宝提现'.$insertData['extract_price'].'元';
         }else if($data['extract_type'] == 'bank'){
             if(!$data['cardnum']) return self::setErrorInfo('请输入银行卡账号');
             if(!$data['bankname']) return self::setErrorInfo('请输入开户行信息');
-            $mark = '使用银联卡'.$insertData['bank_code'].'提现'.$insertData['extract_price'].'元';
+            $mark = '提现'.$js.',使用银联卡'.$insertData['bank_code'].'提现'.$insertData['extract_price'].'元';
         }else if($data['extract_type'] == 'weixin'){
             if(!$data['weixin']) return self::setErrorInfo('请输入微信账号');
-            $mark = '使用微信提现'.$insertData['extract_price'].'元';
+            $mark = '提现'.$js.',使用微信提现'.$insertData['extract_price'].'元';
         }
         self::beginTrans();
         try{
             $res1 = self::create($insertData);
             if(!$res1) return self::setErrorInfo('提现失败');
-            $res2 = User::edit(['brokerage_price'=>$balance],$userInfo['uid'],'uid');
-            $res3 = UserBill::expend('余额提现',$userInfo['uid'],'now_money','extract',$data['money'],$res1['id'],$balance,$mark);
+            $res2 = User::edit([$bl => $balance],$userInfo['uid'],'uid');
+            $res3 = UserBill::expend('积分提现',$userInfo['uid'],'now_money','extract',$data['money'],$res1['id'],$balance,$mark);
             $res = $res2 && $res3;
             if($res){
                 self::commitTrans();

+ 5 - 0
route/api/route.php

@@ -147,6 +147,11 @@ Route::group(function () {
     Route::get('spread/count/:type', 'user.UserBillController/spread_count')->name('spreadCount');//推广 佣金 3/提现 4 总和
     Route::get('spread/banner', 'user.UserBillController/spread_banner')->name('spreadBanner');//推广分销二维码海报生成
     Route::get('integral/list', 'user.UserBillController/integral_list')->name('integralList');//积分记录
+    Route::get('white_integral/list', 'user.UserBillController/white_integral')->name('white_integral');//白积分记录
+    Route::get('purple_integral/list', 'user.UserBillController/purple_integral')->name('purple_integral');//紫积分记录
+    Route::get('green_integral/list', 'user.UserBillController/green_integral')->name('green_integral');//绿积分记录
+    Route::get('business_integral/list', 'user.UserBillController/business_integral')->name('business_integral');//商家积分记录
+    Route::get('paper_ticket/list', 'user.UserBillController/paper_ticket')->name('paper_ticket');//文票记录
     //提现类
     Route::get('extract/bank', 'user.UserExtractController/bank')->name('extractBank');//提现银行/提现最低金额
     Route::post('extract/cash', 'user.UserExtractController/cash')->name('extractCash');//提现申请