Sfoglia il codice sorgente

Merge branch 'liuzj-permission-dev' into test

liuzejian 1 anno fa
parent
commit
ae9e252e0a

+ 156 - 0
app/Console/Commands/Jiesuan/CompanyChargeDayJiesuan.php

@@ -0,0 +1,156 @@
+<?php
+
+namespace App\Console\Commands\Jiesuan;
+
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Redis;
+use Modules\Jiesuan\Services\CompanyUserMoneyService;
+
+class CompanyChargeDayJiesuan extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'Jiesuan:CompanyChargeDayJiesuan {--date= : 结算日期}';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '投放公司每日充值结算';
+
+    /**
+     * Execute the console command.
+     */
+    public function handle(): void
+    {
+        $date = $this->option('date');
+        $chargeInfos = DB::table('orders')
+            ->where('created_at', '>=', $date)
+            ->where('created_at', '<=', $date . ' 23:59:59')
+            ->where('status', '<>', 'UNPAID')
+            ->where('puser_id', '<>', 0)
+            ->select(
+                'puser_id',
+                DB::raw('sum(price) as charge_money')
+            )->groupBy('puser_id')
+            ->get()->keyBy('puser_id');
+        $tuikuanInfos = $this->getTuikuanInfo($date);
+
+
+        $puserIds = $chargeInfos->pluck('puser_id')->merge($tuikuanInfos->pluck('puser_id'))->unique();
+
+        if($puserIds->isNotEmpty()) {
+            $jiesuanInfo = collect();
+            foreach ($puserIds as $puserId) {
+                $jiesuanInfo->put($puserId, (object)[
+                    'charge_money' => $chargeInfos->get($puserId)->charge_money ?? 0,
+                    'tuikuan_money' => $tuikuanInfos->get($puserId)->tuikuan_money ?? 0,
+                ]);
+            }
+            $defaultShareRate = DB::table('company_share_rates')->where('company_uid', 0)->value('share_rate') ?? '89.1';
+            $now = date('Y-m-d H:i:s');
+            $puserIds->chunk(2)->map(function ($item) use ($jiesuanInfo, $defaultShareRate, $date, $now){
+                    $rates = DB::table('company_share_rates')->whereIn('company_uid', $item)
+                        ->select('company_uid', 'share_rate')
+                        ->get()->keyBy('company_uid');
+                    $insertData = [];
+                    foreach ($item as $i) {
+                        $share_rate = $rates->get($i)->share_rate ?? $defaultShareRate;
+                        $jiesuanInfo->get($i)->share_rate = $share_rate;
+                        $jiesuanInfo->get($i)->jiesuan_money =
+                            intval(($jiesuanInfo->get($i)->charge_money - $jiesuanInfo->get($i)->tuikuan_money) * $share_rate) / 100;
+                        $jiesuanInfo->get($i)->tuikuan_money = intval($jiesuanInfo->get($i)->tuikuan_money * $share_rate) / 100;
+
+                        $insertData[] = [
+                            'company_uid' => $i,
+                            'jiesuan_date' => $date,
+                            'charge_money' => $jiesuanInfo->get($i)->charge_money,
+                            'tuikuan_money' => $jiesuanInfo->get($i)->tuikuan_money,
+                            'share_rate' => $jiesuanInfo->get($i)->share_rate,
+                            'jiesuan_money' => $jiesuanInfo->get($i)->jiesuan_money,
+                            'created_at' => $now,
+                            'updated_at' => $now,
+                        ];
+                    }
+                   DB::transaction(function () use ($insertData, $now){
+                       DB::table('jiesuan_records')->insert($insertData);
+                       foreach ($insertData as $item) {
+                           $beforeUserMoneyInfo = CompanyUserMoneyService::userMoneyInfo($item['company_uid']);
+                           $companyUserMoney = DB::table('company_user_money')
+                               ->where('company_uid', $item['company_uid'])->first();
+                           if($companyUserMoney) {
+                               $beforeTotalIncome = $companyUserMoney->total_income;
+                               $afterTotalIncome = bcadd($companyUserMoney->total_income, $item['charge_money'], 2);
+                               DB::table('company_user_money')
+                                   ->where(['company_uid' => $item['company_uid']])
+                                   ->update([
+                                       'total_income' => $afterTotalIncome,
+                                       'updated_at' => $now
+                                   ]);
+                           } else {
+                               $beforeTotalIncome = 0;
+                               $afterTotalIncome = $item['charge_money'];
+                               DB::table('company_user_money')
+                                   ->insert([
+                                       'company_uid' => $item['company_uid'],
+                                       'total_income' => $afterTotalIncome,
+                                       'created_at' => $now, 'updated_at' => $now,
+                                   ]);
+                           }
+                           $currentUserMoneyInfo = CompanyUserMoneyService::userMoneyInfo($item['company_uid']);
+                           DB::table('company_user_money_change_logs')
+                               ->insert([
+                                   'type' => 1,
+                                   'company_uid' => $item['company_uid'],
+                                   'created_at' => $now,
+                                   'log' => \json_encode([
+                                       'desc' => sprintf('总充值变动:[%s元-->%s元],当前总打款:[%s元],总退款变动:[%s元-->%s元],当前审核中:[%s元],余额变动:[%s元-->%s元]',
+                                       $beforeTotalIncome, $currentUserMoneyInfo->total_income,$currentUserMoneyInfo->total_dakuan,
+                                           $beforeUserMoneyInfo->total_tuikuan,
+                                       $currentUserMoneyInfo->total_tuikuan, $currentUserMoneyInfo->tixian_money,
+                                           $beforeUserMoneyInfo->yue_money,
+                                           $currentUserMoneyInfo->yue_money),
+                                       'before' => [
+                                           'total_income' => $beforeUserMoneyInfo->total_income,
+                                           'total_dakuan' => $beforeUserMoneyInfo->total_dakuan,
+                                           'total_tuikuan' => $beforeUserMoneyInfo->total_tuikuan,
+                                           'tixian_money' => $beforeUserMoneyInfo->tixian_money,
+                                           'yue_money' => $beforeUserMoneyInfo->yue_money,
+                                       ],
+                                       'after' => [
+                                           'total_income' => $currentUserMoneyInfo->total_income,
+                                           'total_dakuan' => $currentUserMoneyInfo->total_dakuan,
+                                           'total_tuikuan' => $currentUserMoneyInfo->total_tuikuan,
+                                           'tixian_money' => $currentUserMoneyInfo->tixian_money,
+                                           'yue_money' => $currentUserMoneyInfo->yue_money,
+                                       ],
+                                       'created_at' => $now,
+                                   ], JSON_UNESCAPED_UNICODE)
+                               ]);
+                       }
+                   });
+            });
+
+
+        }
+
+    }
+
+    private function getTuikuanInfo($date) {
+        return DB::table('orders_refund_verify')
+            ->where(['refund_status' => 1])
+            ->where('pay_at', '>=', $date)
+            ->where('pay_at', '<=', $date. ' 23:59:59')
+            ->where('puser_id', '<>', 0)
+            ->select(
+                'puser_id',
+                DB::raw('sum(refund_price) as tuikuan_money')
+            )->groupBy('puser_id')
+            ->get()->keyBy('puser_id');
+    }
+}

+ 6 - 0
app/Console/Kernel.php

@@ -16,6 +16,12 @@ class Kernel extends ConsoleKernel
     protected function schedule(Schedule $schedule)
     {
         $schedule->command('Callback:JuliangAccountRateConfigRefresh')->everyMinute();
+        /**
+         * 投放渠道日结算
+         */
+        $schedule->command('Jiesuan:CompanyChargeDayJiesuan', [
+            '--date' => date('Y-m-d', strtotime('yesterday'))
+        ])->dailyAt('01:00');
     }
 
     /**

+ 2 - 0
modules/Common/Errors/Errors.php

@@ -23,4 +23,6 @@ class Errors
     public const  CALLBACK_RECORD_LOG_ERROR= [500104, '回传日志补传信息缺失'];
     public const  JULIANG_ACCOUNT_PROMOTION_UNIQUE = [500105, '巨量广告账户只允许绑定一个推广'];
     public const  JULIANG_ACCOUNT_CONFIG_NOT_EXISTS = [500106, '回传配置不存在'];
+    public const  TIXIAN_YUE_BUZU = [500201, '提现余额不足'];
+    public const  BANK_CARD_STATUS_ERROR = [500202, '银行卡不存在或当前状态不可提现'];
 }

+ 14 - 0
modules/Jiesuan/Http/Controllers/BankAccountController.php

@@ -105,6 +105,20 @@ class BankAccountController extends CatchController
     }
 
     /**
+     * 公司管理员可用的银行卡列表
+     * @param Request $request
+     */
+    public function listAvailableBankCard(Request $request) {
+        $company_uid = $this->getLoginUserId();
+        return DB::table('bank_cards')
+            ->where([
+                'company_uid' => $company_uid,
+                'status' => 2
+            ])->select('id', 'bank_name', 'card_no', 'sub_bank_name')
+            ->get();
+    }
+
+    /**
      * 合作信息
      * @param Request $request
      */

+ 129 - 0
modules/Jiesuan/Http/Controllers/FinanceCheckController.php

@@ -0,0 +1,129 @@
+<?php
+
+namespace Modules\Jiesuan\Http\Controllers;
+
+use Catch\Base\CatchController;
+use Illuminate\Foundation\Validation\ValidatesRequests;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Modules\Common\Errors\Errors;
+use Modules\Common\Exceptions\CommonBusinessException;
+use Modules\Jiesuan\Services\BusinessmanService;
+use Modules\Jiesuan\Services\CompanyUserMoneyService;
+use Modules\Jiesuan\Services\ConstService;
+use Modules\User\Http\Controllers\UserTrait;
+
+class FinanceCheckController extends CatchController
+{
+    use UserTrait;
+    use ValidatesRequests;
+
+    /**
+     * 列表
+     * @param Request $request
+     */
+    public function list(Request $request) {
+        $this->validate($request, [
+            'status' => 'required|in:1,2,3,4,5'
+        ]);
+        $tixianStartAt = $request->input('tixian_start_at');
+        $tixianEndAt = $request->input('tixian_end_at');
+        $companyUid = $request->input('company_uid');
+        $owner_name = $request->input('owner_name');
+        $isExport = $request->input('is_export', false);
+
+        $sql = DB::table('tixian_records')
+            ->leftJoin('bank_cards','tixian_records.bank_card_id','bank_cards.id')
+            ->where('tixian_records.status', $request->input('status'))
+            ->when($tixianStartAt, function ($query, $tixianStartAt){
+                return $query->where('tixian_records.created_at', '>=', $tixianStartAt);
+            })->when($tixianEndAt, function ($query, $tixianEndAt){
+                return $query->where('tixian_records.created_at', '<=', $tixianEndAt . ' 23:59:59');
+            })->when($owner_name, function ($query, $owner_name) {
+                return $query->where('bank_cards.owner_name', 'like', '%'. $owner_name . '%');
+            })->when($companyUid, function ($query, $companyUid) {
+                return $query->where('tixian_records.company_uid', $companyUid);
+            })
+            ->select('tixian_records.id', 'tixian_records.company_uid', 'bank_cards.owner_name',
+                'tixian_records.status', 'bank_cards.business_id', 'tixian_records.tixian_money', 'tixian_records.created_at',
+            'bank_cards.card_no', 'bank_cards.name_of_payee', 'tixian_records.remark', 'tixian_records.updated_at')
+        ->orderBy('id', 'desc');
+        if($isExport) {
+            $result = $sql->get();
+        } else {
+            $result = $sql->paginate($request->input('limit', 15));
+        }
+        $businessmans = BusinessmanService::list()->keyBy('id');
+        foreach ($result as $item) {
+            $item->business_str = $businessmans->get($item->business_id)->username ?? '';
+            $item->status_str = ConstService::TIXIAN_CHECK_STATUS[$item->status] ?? '';
+        }
+        return $result;
+    }
+
+    /**
+     * 审核
+     * @param Request $request
+     */
+    public function check(Request $request) {
+        $this->validate($request, [
+            'status' => 'required|in:2,3',
+            'id' => 'required'
+        ]);
+
+        DB::table('tixian_records')
+            ->where([
+                'id' => $request->input('id'),
+                'status' => 1
+            ])->update([
+                'status' => $request->input('status'),
+                'updated_at' => date('Y-m-d H:i:s')
+            ]);
+
+        return 'ok';
+    }
+
+    /**
+     * 打款
+     * @param Request $request
+     */
+    public function remit(Request $request) {
+        $this->validate($request, [
+            'status' => 'required|in:4,5',
+            'id' => 'required',
+            'pay_channel' => 'required',
+            'pay_no' => 'required_if:status,4',
+            'remark' => 'nullable|string|max:256'
+        ]);
+
+        DB::table('tixian_records')
+            ->where([
+                'id' => $request->input('id'),
+                'status' => 3
+            ])->update([
+                'updated_at' => date('Y-m-d H:i:s'),
+                'status' => $request->input('status'),
+                'pay_channel' => $request->input('pay_channel'),
+                'pay_no' => $request->input('pay_no'),
+                'remark' => $request->input('remark')
+            ]);
+        return 'ok';
+    }
+
+    /**
+     * 商户的账户余额信息
+     * @param Request $request
+     * @return object|null
+     * @throws \Illuminate\Validation\ValidationException
+     */
+    public function getShanghuAccountInfo(Request $request) {
+        $this->validate($request, [
+            'company_uid' => 'required'
+        ]);
+
+        $accountInfo = CompanyUserMoneyService::userMoneyInfo($request->input('company_uid'));
+        $accountInfo->total_jiesuan = bcsub($accountInfo->total_income,  $accountInfo->total_tuikuan, 2);
+
+        return $accountInfo;
+    }
+}

+ 68 - 17
modules/Jiesuan/Http/Controllers/JiesuanController.php

@@ -6,6 +6,10 @@ use Catch\Base\CatchController;
 use Illuminate\Foundation\Validation\ValidatesRequests;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
+use Modules\Common\Errors\Errors;
+use Modules\Common\Exceptions\CommonBusinessException;
+use Modules\Jiesuan\Services\CompanyUserMoneyService;
+use Modules\Jiesuan\Services\ConstService;
 use Modules\User\Http\Controllers\UserTrait;
 
 class JiesuanController extends CatchController
@@ -23,7 +27,7 @@ class JiesuanController extends CatchController
         $isExport = $request->input('is_export', 0);
         $sql = DB::table('jiesuan_records')
             ->where([
-                'company_uid' => $this->getLoginUserId(),
+                'company_uid' => $this->getCompanyUid($request),
             ])->when($jiesuanDateStartAt, function ($query, $jiesuanDateStartAt) {
                 return $query->where('jiesuan_date', '>=', $jiesuanDateStartAt);
             })
@@ -41,6 +45,8 @@ class JiesuanController extends CatchController
         foreach ($results as $item) {
             $item->share_rate .= '%';
         }
+
+        return $results;
     }
 
     /**
@@ -49,19 +55,7 @@ class JiesuanController extends CatchController
      */
     public function accountInfo(Request $request) {
         $company_uid = $this->getLoginUserId();
-        $moneyInfo = DB::table('company_user_money')
-            ->where('company_uid', $company_uid)
-            ->select('total_income', 'total_dakuan', 'total_tuikuan', 'id')
-            ->first();
-
-        $tixian_money = DB::table('tixian_records')
-            ->where('company_uid', $company_uid)
-            ->whereIn('status', [1,3])
-            ->sum('tixian_money');
-
-        $moneyInfo->tixian_money = $tixian_money;
-        $moneyInfo->yue_money = $moneyInfo->total_income - $moneyInfo->total_tuikuan - $moneyInfo->total_dakuan - $tixian_money;
-        return $moneyInfo;
+        return CompanyUserMoneyService::userMoneyInfo($company_uid);
     }
 
     /**
@@ -74,9 +68,30 @@ class JiesuanController extends CatchController
             'tixian_money' => 'required|numeric|min:500'
         ]);
         $company_uid = $this->getLoginUserId();
-
-//        DB::table('tixian_records')
-//            ->insert()
+        $tixianMoney = $request->input('tixian_money');
+        $userMoneyInfo = CompanyUserMoneyService::userMoneyInfo($company_uid);
+        if($tixianMoney > $userMoneyInfo->yue_money) {
+            CommonBusinessException::throwError(Errors::TIXIAN_YUE_BUZU);
+        }
+        $bank_card_id = $request->input('bank_card_id');
+        $bankCard = DB::table('bank_cards')->where(['id' => $bank_card_id, 'status' => 2])->first();
+        if(!$bankCard) {
+            CommonBusinessException::throwError(Errors::BANK_CARD_STATUS_ERROR);
+        }
+        $now = date('Y-m-d H:i:s');
+        DB::table('tixian_records')
+            ->insert([
+                'tixian_money' => $tixianMoney,
+                'company_uid' => $company_uid,
+                'bank_card_id' => $bank_card_id,
+                'card_no' => $bankCard->card_no,
+                'name_of_payee' => $bankCard->name_of_payee,
+                'status' => 1,
+                'bank_name' => $bankCard->bank_name,
+                'sub_bank_name' => $bankCard->sub_bank_name,
+                'created_at' => $now,
+                'updated_at' => $now,
+            ]);
     }
 
     /**
@@ -84,6 +99,42 @@ class JiesuanController extends CatchController
      * @param Request $request
      */
     public function listTixian(Request $request) {
+        $company_uid = $this->getCompanyUid($request);
+        $this->validate($request, [
+            'status' => 'nullable|integer|in:1,2,3,4,5'
+        ]);
+        $status = $request->input('status');
+        $isExport = $request->input('is_export');
+        $tixianStartAt = $request->input('tixian_start_at');
+        $tixianEndAt = $request->input('tixian_end_at');
+        $sql = DB::table('tixian_records')
+            ->where([
+                'company_uid' => $company_uid,
+            ])->when($status, function ($query, $status){
+                return $query->where('status', $status);
+            })->when($tixianStartAt, function ($query, $tixianStartAt) {
+                return $query->where('created_at', '>=', $tixianStartAt);
+            })->when($tixianEndAt, function ($query, $tixianEndAt) {
+                return $query->where('created_at', '<=', $tixianEndAt. ' 23:59:59');
+            })
+            ->orderBy('id', 'desc');
+        if($isExport) {
+            $result = $sql->get();
+        } else {
+            $result = $sql->paginate($request->input('limit', 15));
+        }
+        foreach ($result as $item) {
+            $item->status_str = ConstService::TIXIAN_CHECK_STATUS[$item->status] ?? '';
+        }
+        return $result;
+    }
 
+    private function getCompanyUid(Request $request) {
+        if($this->isOptimizer()) {
+            return $this->getOptimizerUid();
+        } else {
+            return $request->input('company_uid');
+        }
     }
+
 }

+ 1 - 1
modules/Jiesuan/Services/BusinessmanService.php

@@ -8,7 +8,7 @@ class BusinessmanService
 {
     public static function list() {
         return DB::table('users')
-            ->join('user_has_roles', 'urser.id', 'user_has_roles.user_id')
+            ->join('user_has_roles', 'users.id', 'user_has_roles.user_id')
             ->join('roles', 'user_has_roles.role_id', 'roles.id')
             ->where([
                 'roles.identify' => 'business',

+ 50 - 0
modules/Jiesuan/Services/CompanyUserMoneyService.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace Modules\Jiesuan\Services;
+
+use Illuminate\Support\Facades\DB;
+
+class CompanyUserMoneyService
+{
+    /**
+     * 公司管理员用户金额详情
+     * @param $companyUid
+     * @return null | object
+     * <pre>
+     * {
+     *      'company_uid' : 1, // 公司管理员uid
+     *      'total_income' : 1, // 总收入,
+     *      'total_dakuan' :1, //已打款金额
+     *      'total_tuikuan' : 1, // 总退款金额
+     *      'tixian_money' : 1, // 审核中提现金额
+     *      'yue_money' : 1, // 当前余额
+     * }
+     * </pre>
+     */
+    public static function userMoneyInfo($companyUid)
+    {
+        $moneyInfo = DB::table('company_user_money')
+            ->where('company_uid', $companyUid)
+            ->select('total_income', 'total_dakuan', 'total_tuikuan', 'company_uid')
+            ->first();
+        if(!$moneyInfo) {
+            return (object)[
+                'company_uid' => $companyUid,
+                'total_income' => 0,
+                'total_dakuan' => 0,
+                'total_tuikuan' => 0,
+                'tixian_money' => 0,
+                'yue_money' => 0,
+            ];
+        }
+
+        $tixian_money = DB::table('tixian_records')
+            ->where('company_uid', $companyUid)
+            ->whereIn('status', [1, 3])
+            ->sum('tixian_money');
+
+        $moneyInfo->tixian_money = $tixian_money;
+        $moneyInfo->yue_money = $moneyInfo->total_income - $moneyInfo->total_tuikuan - $moneyInfo->total_dakuan - $tixian_money;
+        return $moneyInfo;
+    }
+}

+ 1 - 1
modules/Jiesuan/Services/ConstService.php

@@ -19,7 +19,7 @@ class ConstService
      */
     public const TIXIAN_CHECK_STATUS = [
         '1' => '待审核',
-        '2' => '审核失败',
+        '2' => '审核不通过',
         '3' => '待打款',
         '4' => '已打款',
         '5' => '打款失败'

+ 25 - 5
modules/Jiesuan/routes/route.php

@@ -1,13 +1,33 @@
 <?php
 
 use Illuminate\Support\Facades\Route;
-use Modules\System\Http\Controllers\NoticesController;
-use Modules\System\Http\Controllers\NoticeTypesController;
-use Modules\Video\Http\Controllers\BankAccountController;
-use Modules\Video\Http\Controllers\VideoCategoryController;
-use Modules\Video\Http\Controllers\VideoController;
+use Modules\Jiesuan\Http\Controllers\BankAccountController;
+use Modules\Jiesuan\Http\Controllers\FinanceCheckController;
+use Modules\Jiesuan\Http\Controllers\JiesuanController;
+use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\F;
+
 
 Route::prefix('jiesuanManage')->group(function () {
+    Route::prefix('bankAccount')->group(function (){
+        Route::get('hezuoInfo', [BankAccountController::class, 'hezuoInfo']);
+        Route::get('listCompanyCard', [BankAccountController::class, 'listCompanyCard']);
+        Route::get('listAvailableBankCard', [BankAccountController::class, 'listAvailableBankCard']);
+        Route::get('listBank', [BankAccountController::class, 'listBank']);
+        Route::get('listShangwu', [BankAccountController::class, 'listShangwu']);
+        Route::post('addCompanyCard', [BankAccountController::class, 'addCompanyCard']);
+    });
+
+    Route::prefix('jiesuan')->group(function(){
+        Route::get('listTixian', [JiesuanController::class, 'listTixian']);
+        Route::get('list', [JiesuanController::class, 'list']);
+        Route::get('accountInfo', [JiesuanController::class, 'accountInfo']);
+        Route::post('tixian', [JiesuanController::class, 'tixian']);
+    });
 
+    Route::prefix('financeCheck')->group(function(){
+       Route::get('list', [FinanceCheckController::class, 'list']);
+       Route::post('check', [FinanceCheckController::class, 'check']);
+       Route::post('remit', [FinanceCheckController::class, 'remit']);
+    });
 });
 

+ 13 - 2
modules/User/Http/Controllers/UserTrait.php

@@ -76,11 +76,22 @@ trait UserTrait
         return compact('loginUser', 'loginUserRoles', 'operateUserRoles', 'operateUser');
     }
 
+    /**
+     * 获取优化师用户uid
+     * @return int|null
+     */
     public function getOptimizerUid() {
-        $currentUserRoles = $this->listUserRoles();
-        if($currentUserRoles->contains('optimizer')) {
+        if($this->isOptimizer()) {
             return $this->getCurrentUser()->id;
         }
         return null;
     }
+
+    /**
+     * 是否是优化师
+     * @return bool
+     */
+    public function isOptimizer() {
+        return $this->listUserRoles()->contains('optimizer');
+    }
 }

+ 46 - 0
tests/Console/Commands/Jiesuan/CompanyChargeDayJiesuanTest.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace Tests\Console\Commands\Jiesuan;
+
+use App\Console\Commands\Jiesuan\CompanyChargeDayJiesuan;
+use Illuminate\Support\Facades\DB;
+use PHPUnit\Framework\TestCase;
+
+class CompanyChargeDayJiesuanTest extends \Tests\TestCase
+{
+
+    public function testHandle()
+    {
+        $this->prepareData();
+    }
+
+    private function prepareData() {
+
+        $startTimestamp = strtotime('yesterday') - 24 * 3600;
+
+        foreach (range(1, 100) as $i) {
+            $orders[] = [
+                'uid' => 100000+$i,
+                'promotion_id' => 1000,
+                'user_id' => 50 + $i,
+                'puser_id' => [2, 15][rand(0,1)],
+                'price' => rand(20, 100),
+                'miniprogram_id' => 1,
+                'pay_product_id' => 1,
+                'create_ip' => '192.168.0.1',
+                'status' => ['PAID', 'UNPAID'][rand(0,1)],
+                'trade_no' => uniqid('fake-1-'),
+                'transaction_id' => uniqid('fake-2-'),
+                'third_orderid' => uniqid('fake-3-'),
+                'order_type' => 'COIN',
+                'pay_merchant_source' => 'PALMPAY',
+                'video_id' => 0,
+                'video_series_sequence' => 0,
+                'created_at' => date('Y-m-d H:i:s', $startTimestamp + $i * 800),
+                'updated_at' => date('Y-m-d H:i:s', $startTimestamp + $i * 800),
+            ];
+        }
+
+        DB::table('orders')->insert($orders);
+    }
+}

+ 101 - 0
tests/Jiesuan/Http/Controllers/BankAccountControllerTest.php

@@ -0,0 +1,101 @@
+<?php
+
+namespace Tests\Jiesuan\Http\Controllers;
+
+use Modules\Jiesuan\Http\Controllers\BankAccountController;
+use PHPUnit\Framework\TestCase;
+use Tests\UsedTestCase;
+
+class BankAccountControllerTest extends UsedTestCase
+{
+
+    public function testHezuoInfo()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/jiesuanManage/bankAccount/hezuoInfo', []);
+//        $res->dump();
+        $this->dumpJson($res);
+    }
+    public function testaddCompanyCard()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/jiesuanManage/bankAccount/addCompanyCard', [
+            'owner_name' => 'fsdadfasfsaf',
+            'name_of_payee' => 'jlkjkljklj',
+            'card_no' => '21432515',
+            'bank_name' => '中国银行',
+            'sub_bank_name' => '第一支行',
+            'phone_of_payee' => '143214141',
+            'business_id' => 8
+        ]);
+        $res->dump();
+
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/jiesuanManage/bankAccount/addCompanyCard', [
+            'id' => 1,
+            'owner_name' => 'fsdadfasfsaf2222',
+            'name_of_payee' => 'jlkjkljklj3333',
+            'card_no' => '2143251544',
+            'bank_name' => '中国银行',
+            'sub_bank_name' => '第一支行22',
+            'phone_of_payee' => '14321414123323232',
+            'business_id' => 8
+        ]);
+        $res->dump();
+    }
+
+    public function testaddCompanyCard1() {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/jiesuanManage/bankAccount/addCompanyCard', [
+            'id' => 1,
+            'owner_name' => 'fasd',
+            'name_of_payee' => 'fdsa',
+            'card_no' => '2143251544',
+            'bank_name' => '中国银行',
+            'sub_bank_name' => '第一支行22',
+            'phone_of_payee' => '1231',
+            'business_id' => 8
+        ]);
+        $res->dump();
+    }
+
+    public function testlistShangwu()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/jiesuanManage/bankAccount/listShangwu');
+//        $res->dump();
+        $this->dumpJson($res);
+    }
+    public function testlistBank()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/jiesuanManage/bankAccount/listBank');
+//        $res->dump();
+        $this->dumpJson($res);
+    }
+
+    public function testlistCompanyCard()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/jiesuanManage/bankAccount/listCompanyCard');
+//        $res->dump();
+        $this->dumpJson($res);
+    }
+    public function testlistAvailableBankCard()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/jiesuanManage/bankAccount/listAvailableBankCard');
+//        $res->dump();
+        $this->dumpJson($res);
+    }
+
+
+}

+ 47 - 0
tests/Jiesuan/Http/Controllers/FinanceCheckControllerTest.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace Tests\Jiesuan\Http\Controllers;
+
+use Modules\Jiesuan\Http\Controllers\FinanceCheckController;
+use PHPUnit\Framework\TestCase;
+use Tests\UsedTestCase;
+
+class FinanceCheckControllerTest extends UsedTestCase
+{
+
+    public function testList()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/jiesuanManage/financeCheck/list',[
+            'status' => 4,
+//            'owner_name' => 'fsd1'
+        ]);
+//        $res->dump();
+        $this->dumpJson($res);
+    }
+    public function testCheck()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/jiesuanManage/financeCheck/check',[
+            'status' => 2,
+            'id' => 1,
+        ]);
+        $res->dump();
+    }
+
+    public function testremit()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/jiesuanManage/financeCheck/remit',[
+            'status' => 4,
+            'id' => 1,
+            'pay_channel' => '治愈',
+            'pay_no' => '13214321',
+            'remark' => 'kjlj',
+        ]);
+        $res->dump();
+    }
+}

+ 47 - 0
tests/Jiesuan/Http/Controllers/JiesuanControllerTest.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace Tests\Jiesuan\Http\Controllers;
+
+use Modules\Jiesuan\Http\Controllers\JiesuanController;
+use PHPUnit\Framework\TestCase;
+use Tests\UsedTestCase;
+
+class JiesuanControllerTest extends UsedTestCase
+{
+
+    public function testList()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/jiesuanManage/jiesuan/list');
+        $this->dumpJson($res);
+    }
+    public function testaccountInfo()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/jiesuanManage/jiesuan/accountInfo');
+//        $res->dump();
+        $this->dumpJson($res);
+    }
+ public function testtixian()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/jiesuanManage/jiesuan/tixian', [
+            'bank_card_id' => 1,
+            'tixian_money' => 9358,
+        ]);
+        $res->dump();
+    }
+    public function testlistTixian()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('get','http://localhost/api/jiesuanManage/jiesuan/listTixian', [
+//            'status' => 5
+        ]);
+        $res->dump();
+//        $this->dumpJson($res);
+    }
+}

+ 2 - 2
tests/UsedTestCase.php

@@ -13,11 +13,11 @@ abstract class UsedTestCase extends BaseTestCase
     {
         parent::setUp(); // TODO: Change the autogenerated stub
         $tokenInfo = $this->post('http://localhost/api/login', [
-//            'email' => 'catch@admin.com',
+            'email' => 'catch@admin.com',
             'remember' => false,
 //            'email' => 'xiaoli@qq.com',
             'password' => 'catchadmin',
-            'email' => 'aa4@test.com',
+//            'email' => 'aa4@test.com',
         ])->json();
         $this->token = $tokenInfo['data']['token'];
     }