Просмотр исходного кода

Merge branch 'order' into test

zqwang 1 год назад
Родитель
Сommit
b00b1c07cc

+ 51 - 1
modules/Jiesuan/Http/Controllers/VerifyBankInfoController.php

@@ -9,7 +9,57 @@
 
 namespace Modules\Jiesuan\Http\Controllers;
 
-class VerifyBankInfoController
+use Catch\Base\CatchController;
+
+use Catch\Exceptions\FailedException;
+use Illuminate\Http\Request;
+use Modules\Jiesuan\Http\Requests\VerifyCheckRequest;
+use Modules\Jiesuan\Services\BusinessmanService;
+use Modules\Jiesuan\Services\VerifyService;
+use Modules\User\Http\Controllers\UserTrait;
+
+class VerifyBankInfoController extends CatchController
 {
+    use UserTrait;
+
+    public function list(Request $request)
+    {
+        $isAll = $request->input('is_all', false);
+        $param = $request->all();
+
+        return VerifyService::verifyList($param, $isAll);
+    }
+
+    /**
+     *  商务列表选择项
+     * name: businessOption
+     * @param Request $request
+     * @return \Illuminate\Support\Collection
+     * date 2023/05/30 09:54
+     */
+    public function businessOption(Request $request)
+    {
+        return BusinessmanService::list($request->all());
+    }
+
+    public function check(VerifyCheckRequest $request)
+    {
+        $userContext = $this->getUserContext(null);
+        if (!$userContext['loginUserRoles']->contains('administrator')) {
+            throw  new  FailedException("没有操作权限");
+        }
+        $param = [
+            'status' => $request->input('status'),
+            'checked_user' => [
+                "id"=> $userContext['loginUser']->id,
+                "user_name"=> $userContext['loginUser']->username,
+                "email"=> $userContext['loginUser']->email,
+            ],
+            'checked_at' => get_date(),
+            'remark' => $request->input('remark',"")
+        ];
+
+        return VerifyService::checkBankInfo($request->input("id"),$param);
+    }
 
 }

+ 42 - 0
modules/Jiesuan/Http/Requests/VerifyCheckRequest.php

@@ -0,0 +1,42 @@
+<?php
+/**
+ *
+ * @file:VerifyCheckRequest.php
+ * @Date: 2023/5/30
+ * @Time: 14:02
+ */
+
+
+namespace Modules\Jiesuan\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class VerifyCheckRequest extends FormRequest
+{
+    /**
+     * rules
+     *
+     * @return array
+     */
+    public function rules(): array
+    {
+        return [
+            'id' => [ 'required', 'Integer', "gt:0", ],
+            'status' => [ 'required','Integer', "in:2,3"]
+        ];
+    }
+
+    /**
+     * messages
+     *
+     * @return string[]
+     */
+    public function messages(): array
+    {
+        return [
+            'refund_id.required' => '审核信息id必填',
+            'refund_id' => '审核信息id',
+            'status' => '审核状态不正确',
+        ];
+    }
+}

+ 18 - 0
modules/Jiesuan/Models/BankCards.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace Modules\Jiesuan\Models;
+
+use Modules\Common\Models\BaseModel;
+
+
+class BankCards extends BaseModel
+{
+    protected $table = 'bank_cards';
+
+    protected $fillable = [
+        'id', 'owner_name', 'name_of_payee', 'card_no', 'bank_name', 'sub_bank_name', 'phone_of_payee', 'business_id', 'status', 'remark', 'checked_at', 'created_at', 'updated_at', 'company_uid','checked_user'
+
+    ];
+
+    protected $casts = ['checked_user'=> 'array'];
+}

+ 22 - 0
modules/Jiesuan/Services/BaseService.php

@@ -0,0 +1,22 @@
+<?php
+/**
+ *
+ * @file:BaseService.php
+ * @Date: 2023/5/30
+ * @Time: 10:13
+ */
+
+
+namespace Modules\Jiesuan\Services;
+
+use Catch\Exceptions\FailedException;
+
+class BaseService
+{
+    protected static  function  throwErrMsg($msg,$code = ""){
+        if ($code){
+            throw  new FailedException($msg,$code);
+        }
+        throw  new FailedException($msg);
+    }
+}

+ 17 - 3
modules/Jiesuan/Services/BusinessmanService.php

@@ -6,14 +6,28 @@ use Illuminate\Support\Facades\DB;
 
 class BusinessmanService
 {
-    public static function list() {
-        return DB::table('users')
+    /**
+     *  商务列表
+     * name: list
+     * @param array $param
+     * @return \Illuminate\Support\Collection
+     * date 2023/05/30 10:01
+     */
+    public static function list($param = []) {
+        $list = DB::table('users')
             ->join('user_has_roles', 'users.id', 'user_has_roles.user_id')
             ->join('roles', 'user_has_roles.role_id', 'roles.id')
             ->where([
                 'roles.identify' => 'business',
                 'users.status' => 1,
-            ])->select('users.id', 'users.username', 'users.email')
+            ]);
+        if (getProp($param,'name','')){
+            $list->where('users.username','like',"%".$param['name']."%");
+        }
+        if (getProp($param,'id',0)){
+            $list->where('users.id',$param['id']);
+        }
+        return $list->select('users.id', 'users.username', 'users.email')
             ->get();
     }
 }

+ 108 - 0
modules/Jiesuan/Services/VerifyService.php

@@ -0,0 +1,108 @@
+<?php
+/**
+ *
+ * @file:VerifyService.php
+ * @Date: 2023/5/30
+ * @Time: 10:12
+ */
+
+
+namespace Modules\Jiesuan\Services;
+
+use Modules\Jiesuan\Models\BankCards;
+
+class VerifyService extends BaseService
+{
+
+    /**
+     *  审核列表
+     * name: verifyList
+     * @param array $param
+     * date 2023/05/30 10:15
+     */
+    public static function verifyList(array $param = [], $isAll = false)
+    {
+        $list = self::QuerySql($param);
+        $list->select('bank_cards.id', 'bank_cards.owner_name', 'bank_cards.name_of_payee', 'bank_cards.status', 'bank_cards.card_no', 'bank_cards.bank_name', 'bank_cards.phone_of_payee', 'bank_cards.bank_name', 'bank_cards.remark', 'bank_cards.created_at', 'bank_cards.checked_at', 'bank_cards.company_uid', 'users.username as business_name');
+        if ($isAll) {
+            $list = $list->get();
+        } else {
+            $list = $list->paginate(getProp($param, 'limit', 10));
+        }
+        if (!$list->isEmpty()) {
+            foreach ($list as $val) {
+                $val->status_text = ConstService::BANK_CARD_CHECK_STATUS[$val->status] ?? "-";
+            }
+        }
+        return $list;
+    }
+
+
+    private static function QuerySql(array $param)
+    {
+        $sql = BankCards::query()->leftJoin('users', 'users.id', '=', 'bank_cards.business_id');
+        if (getProp($param, 'status', 1) == 1) {
+            $sql->where('bank_cards.status', '=', 1);
+        } else {
+            $sql->where('bank_cards.status', '>', 1);
+        }
+
+        // 商户名称
+        if (getProp($param, 'owner_name', '')) {
+            $sql->where('bank_cards.owner_name', "like", "%{$param['owner_name']}%");
+        }
+        // 商务
+        if (getProp($param, 'bank_cards.business_id', 0)) {
+            $sql->where('bank_cards.business_id', $param['business_id']);
+        }
+        // 创建时间
+        if (getProp($param, 'created_at_start')) {
+            $sql->where('bank_cards.created_at', '>=', $param['created_at_start']);
+        }
+        if (getProp($param, 'created_at_end')) {
+            $sql->where('bank_cards.created_at', "<=", $param['created_at_end']);
+        }
+        // 审核时间
+        if (getProp($param, 'checked_at_start')) {
+            $sql->where('bank_cards.checked_at', '>=', $param['checked_at_start']);
+        }
+        if (getProp($param, 'checked_at_end')) {
+            $sql->where('bank_cards.checked_at', "<=", $param['checked_at_end']);
+        }
+        return $sql;
+    }
+
+    /**
+     *  更新银行卡审核信息
+     * name: checkBankInfo
+     * @param mixed $id
+     * @param array $param
+     * $param = [
+     * 'status' => 2,
+     * 'checked_user' => [ // 审核人信息
+     *      "id"=>1,
+     *      "user_name"=>, //
+     *      "email"=>
+     *      ];
+     *     'checked_at' => '2023-02-02 09:28:56' // 审核时间
+     *     'remark' =>  '' // 备注
+     *
+     * ];
+     * date 2023/05/30 14:19
+     */
+    public static function checkBankInfo(mixed $id, array $param)
+    {
+        $info = BankCards::where('id', $id)->where('status', '>', 0)->first();
+        if (empty($info)) {
+            self::throwErrMsg("银行卡信息不存在或已删除,请刷新重试!");
+        }
+        if ($info['status'] != 1) {
+            self::throwErrMsg("改收款信息已审核,无需再次审核");
+        }
+        $res = BankCards::where('id', $id)->update($param);
+        if ($res) {
+            return "操作成功";
+        }
+        self::throwErrMsg('操作失败');
+    }
+}

+ 8 - 0
modules/Jiesuan/routes/route.php

@@ -30,5 +30,13 @@ Route::prefix('jiesuanManage')->group(function () {
        Route::post('remit', [FinanceCheckController::class, 'remit']);
        Route::get('getShanghuAccountInfo', [FinanceCheckController::class, 'getShanghuAccountInfo']);
     });
+
+    // 结算账户审核
+    Route::prefix('verify')->group(function (){
+        Route::any('list',[\Modules\Jiesuan\Http\Controllers\VerifyBankInfoController::class,"list"]);
+        // 商户选择项
+        Route::any('business/option',[\Modules\Jiesuan\Http\Controllers\VerifyBankInfoController::class,"businessOption"]);
+        Route::any('check',[\Modules\Jiesuan\Http\Controllers\VerifyBankInfoController::class,"check"]);
+    });
 });