From 14e1972f8f5f5df11094b8fb0076962da12f9614 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Sat, 25 Nov 2023 14:51:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E7=81=B5=E6=B4=BB?= =?UTF-8?q?=E7=94=A8=E5=B7=A5=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/use-staff/README.md | 1 + plugins/use-staff/callbacks.php | 14 + plugins/use-staff/lang/en/locale.js | 8 + plugins/use-staff/lang/en/test.php | 5 + plugins/use-staff/lang/zh-CN/locale.js | 6 + plugins/use-staff/lang/zh-CN/test.php | 5 + plugins/use-staff/package.json | 11 + plugins/use-staff/src/PluginApplication.php | 113 ++++++ .../use-staff/src/admin/IndexController.php | 103 ++++++ .../src/admin/WithdrawalController.php | 55 +++ plugins/use-staff/src/api/IndexController.php | 65 ++++ .../use-staff/src/api/NotifyController.php | 59 +++ plugins/use-staff/src/models/ExternalApi.php | 341 ++++++++++++++++++ plugins/use-staff/src/models/UseStaff.php | 152 ++++++++ .../use-staff/src/models/UseStaffSalary.php | 55 +++ .../views/admin/index/index.blade.php | 160 ++++++++ .../use-staff/views/admin/index/set.blade.php | 88 +++++ .../views/admin/withdrawal/index.blade.php | 138 +++++++ plugins/use-staff/views/config.tpl | 0 19 files changed, 1379 insertions(+) create mode 100644 plugins/use-staff/README.md create mode 100644 plugins/use-staff/callbacks.php create mode 100644 plugins/use-staff/lang/en/locale.js create mode 100644 plugins/use-staff/lang/en/test.php create mode 100644 plugins/use-staff/lang/zh-CN/locale.js create mode 100644 plugins/use-staff/lang/zh-CN/test.php create mode 100644 plugins/use-staff/package.json create mode 100644 plugins/use-staff/src/PluginApplication.php create mode 100644 plugins/use-staff/src/admin/IndexController.php create mode 100644 plugins/use-staff/src/admin/WithdrawalController.php create mode 100644 plugins/use-staff/src/api/IndexController.php create mode 100644 plugins/use-staff/src/api/NotifyController.php create mode 100644 plugins/use-staff/src/models/ExternalApi.php create mode 100644 plugins/use-staff/src/models/UseStaff.php create mode 100644 plugins/use-staff/src/models/UseStaffSalary.php create mode 100644 plugins/use-staff/views/admin/index/index.blade.php create mode 100644 plugins/use-staff/views/admin/index/set.blade.php create mode 100644 plugins/use-staff/views/admin/withdrawal/index.blade.php create mode 100644 plugins/use-staff/views/config.tpl diff --git a/plugins/use-staff/README.md b/plugins/use-staff/README.md new file mode 100644 index 00000000..0fc95ad5 --- /dev/null +++ b/plugins/use-staff/README.md @@ -0,0 +1 @@ +## 灵活用工 diff --git a/plugins/use-staff/callbacks.php b/plugins/use-staff/callbacks.php new file mode 100644 index 00000000..d0311bfb --- /dev/null +++ b/plugins/use-staff/callbacks.php @@ -0,0 +1,14 @@ + function ($plugins) { + \Artisan::call('migrate',['--path'=>'plugins/use-staff/migrations','--force'=>true]); + }, + app\common\events\PluginWasDisabled::class => function ($plugin) { + + + }, + app\common\events\PluginWasDeleted::class => function () { + \Artisan::call('migrate:rollback',['--path'=>'plugins/use-staff/migrations']); + } +]; diff --git a/plugins/use-staff/lang/en/locale.js b/plugins/use-staff/lang/en/locale.js new file mode 100644 index 00000000..6f5de3aa --- /dev/null +++ b/plugins/use-staff/lang/en/locale.js @@ -0,0 +1,8 @@ + +"use strict"; + +$.extend($.locales['en'], { + 'welfare': { + test: "JavaScript i18n test: English" + } +}); diff --git a/plugins/use-staff/lang/en/test.php b/plugins/use-staff/lang/en/test.php new file mode 100644 index 00000000..8999558a --- /dev/null +++ b/plugins/use-staff/lang/en/test.php @@ -0,0 +1,5 @@ +'this is test title' +]; \ No newline at end of file diff --git a/plugins/use-staff/lang/zh-CN/locale.js b/plugins/use-staff/lang/zh-CN/locale.js new file mode 100644 index 00000000..1be84a97 --- /dev/null +++ b/plugins/use-staff/lang/zh-CN/locale.js @@ -0,0 +1,6 @@ + +$.extend($.locales['zh-CN'], { + 'welfare': { + test: "JavaScript i18n test: 简体中文" + } +}); diff --git a/plugins/use-staff/lang/zh-CN/test.php b/plugins/use-staff/lang/zh-CN/test.php new file mode 100644 index 00000000..14fbcffc --- /dev/null +++ b/plugins/use-staff/lang/zh-CN/test.php @@ -0,0 +1,5 @@ +'测试标题' +]; \ No newline at end of file diff --git a/plugins/use-staff/package.json b/plugins/use-staff/package.json new file mode 100644 index 00000000..c3219864 --- /dev/null +++ b/plugins/use-staff/package.json @@ -0,0 +1,11 @@ +{ + "name": "use-staff", + "terminal": "wechat|min|wap", + "version": "1.0.1", + "title": "灵活用工", + "description": "灵活用工", + "author": "zzw", + "url": "", + "namespace": "Yunshop\\UseStaff", + "config": "config.tpl" +} \ No newline at end of file diff --git a/plugins/use-staff/src/PluginApplication.php b/plugins/use-staff/src/PluginApplication.php new file mode 100644 index 00000000..d6a764f3 --- /dev/null +++ b/plugins/use-staff/src/PluginApplication.php @@ -0,0 +1,113 @@ +setPluginMenu('use-staff',[ + 'name' => '灵活用工', + 'type' => 'marketing', + 'url' => 'plugin.use-staff.admin.index.index',// url 可以填写http 也可以直接写路由 + 'url_params' => '',//如果是url填写的是路由则启用参数否则不启用 + 'permit' => 1,//如果不设置则不会做权限检测 + 'menu' => 1,//如果不设置则不显示菜单,子菜单也将不显示 + 'icon' => '',//菜单图标 + 'list_icon' => 'use-staff', + 'item' => 'plugin_use_staff', + 'parents' => [], + 'top_show' => 0, + 'left_first_show' => 0, + 'left_second_show' => 1, + 'child' => [ + 'plugin_use_staff_index' => [ + 'name' => '人员管理', + 'permit' => 1, + 'menu' => 1, + 'icon' => '', + 'url' => 'plugin.use-staff.admin.index.index', + 'url_params' => '', + 'item' => 'plugin_use_staff_index', + 'parents' => ['use-staff'], + 'child' => [ + // 权限补充 + 'plugin_use_staff_index_index' => [ + 'name' => '人员管理', + 'url' => 'plugin.use-staff.admin.index.index', + 'url_params' => '', + 'permit' => 1, + 'menu' => 0, + 'icon' => '', + 'item' => 'plugin_use_staff_index_index', + 'parents' => ['plugin_use_staff','plugin_use_staff_index'], + ], + 'plugin_use_staff_index_refreshInfo' => [ + 'name' => '刷新信息', + 'url' => 'plugin.use-staff.admin.index.refreshInfo', + 'url_params' => '', + 'permit' => 1, + 'menu' => 0, + 'icon' => '', + 'item' => 'plugin_use_staff_index_refreshInfo', + 'parents' => ['plugin_use_staff','plugin_use_staff_index'], + ], + ] + ], + 'plugin_use_staff_withdrawal' => [ + 'name' => '提现打款记录', + 'permit' => 1, + 'menu' => 1, + 'icon' => '', + 'url' => 'plugin.use-staff.admin.withdrawal.index', + 'url_params' => '', + 'item' => 'plugin_use_staff_withdrawal', + 'parents' => ['use-staff'], + 'child' => [ + // 权限补充 + 'plugin_use_staff_withdrawal_index' => [ + 'name' => '提现打款记录', + 'url' => 'plugin.use-staff.admin.withdrawal.index', + 'url_params' => '', + 'permit' => 1, + 'menu' => 0, + 'icon' => '', + 'item' => 'plugin_use_staff_withdrawal_index', + 'parents' => ['plugin_use_staff','plugin_use_staff_withdrawal'], + ], + 'plugin_use_staff_withdrawal_refreshInfo' => [ + 'name' => '刷新信息', + 'url' => 'plugin.use-staff.admin.withdrawal.refreshInfo', + 'url_params' => '', + 'permit' => 1, + 'menu' => 0, + 'icon' => '', + 'item' => 'plugin_use_staff_withdrawal_refreshInfo', + 'parents' => ['plugin_use_staff','plugin_use_staff_withdrawal'], + ], + ] + ], + /*'plugin_use_staff_index_set' => [ + 'name' => '基础设置', + 'permit' => 1, + 'menu' => 1, + 'icon' => '', + 'url' => 'plugin.use-staff.admin.index.set', + 'url_params' => '', + 'item' => 'plugin_use_staff_index_set', + 'parents' => ['use-staff'], + ],*/ + ] + ]); + } + + + public function boot(){ + $events = app('events'); + + + + + + + } +} \ No newline at end of file diff --git a/plugins/use-staff/src/admin/IndexController.php b/plugins/use-staff/src/admin/IndexController.php new file mode 100644 index 00000000..12950886 --- /dev/null +++ b/plugins/use-staff/src/admin/IndexController.php @@ -0,0 +1,103 @@ +input('page_size',10); + $search = request()->input('search'); + // 获取列表信息 + $result = UseStaff::getList($pageSize,$search); + + $data = [ + 'list' => $result['data'], + 'pager' => PaginationHelper::show($result['total'],$result['current_page'],$result['per_page']), + 'search' => $search + ]; + + return view('Yunshop\UseStaff::admin.index.index',$data)->render(); + } + /** + * Common: 刷新员工入驻信息 + * Author: wu-hui + * Time: 2023/10/09 14:31 + * @return mixed + */ + public function refreshInfo(){ + try{ + // 参数获取 + $id = request()->input('id'); + // 刷新信息 + $memberId = UseStaff::where('id',$id)->value('member_id'); + (new ExternalApi())->personnelResult($memberId); + // 刷新完成 + + return $this->message('刷新成功'); + }catch(\Exception $e){ + return $this->message($e->getMessage()); + } + } + + + + + public function test(){ + + // 员工入驻 + $info = [ + 'uid' => '228', + 'name' => '胡治金',// 账号名称 + 'tel' => 18982255122,// 手机号 + 'card_type' => 1,// 卡类型:1=对私,2=对公 + // 'bank_sub_name' => '',//开户银行支行名称,卡类型为2-对公必填 + 'account_id_start' => '20201107',// 证件有效期开始时间,格式:YYYYMMDD + 'bank_act_name' => '胡治金',// 银行卡持有人姓名 + 'card_num' => '6217253100008301299',// 银行卡卡号 + 'account_id' => '511321198404020899',// 银行卡持有人身份证号码 + 'mer_type' => 3,// 商户类型:1=个体户,3=个人 + ]; + (new ExternalApi())->personnelAccess($info); + // 员工入驻 - 结果查询 + /*$staffInfo = (new ExternalApi())->personnelResult(592217313649454896); + debug($staffInfo);*/ + // 员工签约 + // $result = (new ExternalApi())->personalContractCreate(592217313649454896); + // 员工签约状态查询 + // $result = (new ExternalApi())->personalContractQuery(592217313649454896); + // debug($result); + // 费用代发接外部订单号(新) + + + + // $rand = rand(0,50) / 100; + // if($rand == 0) $rand = 0.1; + // $info = [ + // 'uid' => '228', + // 'month' => date("Ym",time()), + // 'member_id' => '592217313649454896', + // 'salary' => $rand + // ]; + // $result = (new ExternalApi())->salaryModelOutOrder($info); + // debug(['请求结果'=>$result]); + // // 费用代发 - 结果查询 + // $result = (new ExternalApi())->salaryOutOrderResult('SHB000007570'); + // debug($result); + } + + + + +} diff --git a/plugins/use-staff/src/admin/WithdrawalController.php b/plugins/use-staff/src/admin/WithdrawalController.php new file mode 100644 index 00000000..6ef78984 --- /dev/null +++ b/plugins/use-staff/src/admin/WithdrawalController.php @@ -0,0 +1,55 @@ +input('page_size',10); + $search = request()->input('search'); + // 获取列表信息 + $result = UseStaffSalary::getList($pageSize,$search); + + $data = [ + 'list' => $result['data'], + 'pager' => PaginationHelper::show($result['total'],$result['current_page'],$result['per_page']), + 'search' => $search + ]; + + return view('Yunshop\UseStaff::admin.withdrawal.index',$data)->render(); + } + /** + * Common: 刷新提现打款信息 + * Author: wu-hui + * Time: 2023/10/09 15:00 + * @return mixed + */ + public function refreshInfo(){ + try{ + // 参数获取 + $id = request()->input('id'); + // 刷新信息 + $attachId = UseStaffSalary::where('id',$id)->value('attach_id'); + (new ExternalApi())->salaryOutOrderResult($attachId); + // 刷新完成 + + return $this->message('刷新成功'); + }catch(\Exception $e){ + return $this->message($e->getMessage()); + } + } + + +} diff --git a/plugins/use-staff/src/api/IndexController.php b/plugins/use-staff/src/api/IndexController.php new file mode 100644 index 00000000..1b1f9831 --- /dev/null +++ b/plugins/use-staff/src/api/IndexController.php @@ -0,0 +1,65 @@ +getMemberId(); + $field = ['id','name','tel','card_type','bank_sub_name','account_id_start','bank_act_name','card_num','account_id','mer_type','status','member_id','trans_seq_id']; + $staff = UseStaff::getSingleInfo(['uid'=>$uid],$field,true); + + return $this->successJson('获取成功',$staff ?? []); + } + /** + * Common: 员工入驻申请 | 编辑信息 + * Author: wu-hui + * Time: 2023/10/10 12:02 + * @return \Illuminate\Http\JsonResponse + */ + public function applyToJoin(){ + // 参数获取 + $info = request()->input('info'); + $info['uid'] = \YunShop::app()->getMemberId(); + try{ + $applyResult = (new ExternalApi())->personnelAccess($info); + (new ExternalApi())->personnelResult($applyResult['memberId'],$applyResult['transSeqId']); + + return $this->successJson('申请成功'); + }catch(\Exception $e){ + return $this->errorJson($e->getMessage()); + } + } + /** + * Common: 获取合同信息 + * Author: wu-hui + * Time: 2023/10/10 14:35 + * @return \Illuminate\Http\JsonResponse + */ + public function getContractInfo(){ + try{ + $uid = \YunShop::app()->getMemberId(); + $result = (new ExternalApi())->personalContractCreate($uid); + + return $this->successJson('合同信息',[ + 'down_url' => urldecode($result['downUrl']), + 'sign_url' => urldecode($result['signUrl']), + 'view_url' => urldecode($result['viewUrl']) + ]); + }catch(\Exception $e){ + return $this->errorJson($e->getMessage()); + } + } + + +} \ No newline at end of file diff --git a/plugins/use-staff/src/api/NotifyController.php b/plugins/use-staff/src/api/NotifyController.php new file mode 100644 index 00000000..2a9b5d5b --- /dev/null +++ b/plugins/use-staff/src/api/NotifyController.php @@ -0,0 +1,59 @@ +all(); + \Log::debug('------- [异步通知]员工入驻 - 申请入驻 -----',$info); + $staff = UseStaff::getSingleInfo(['order_id'=>$info['transSeqId']]); + // 修改状态 + UseStaff::uniacid()->where('member_id',$info['memberId'])->update([ + 'status' => $info['state'] + ]); + + return 'RECV_ORD_ID_'.$staff['order_id']; + }catch(\Exception $e){ + \Log::debug('------- [异步通知]员工入驻 - 申请入驻 - 错误 -----',$e->getMessage()); + } + + return false; + } + /** + * Common: 费用代发 - 申请代发 - 异步通知 + * Author: wu-hui + * Time: 2023/10/09 11:54 + * @return string + */ + public function salary(){ + try{ + // 参数获取并且处理 + $info = request()->all(); + \Log::debug('------- [异步通知]费用代发 - 申请代发 -----',$info); + // 为了保证数据的一致性 这里需要调用查询接口进行处理 + (new ExternalApi())->salaryOutOrderResult($info['attachId']); + + return 'RECV_ORD_ID_'.$info['orderId']; + }catch(\Exception $e){ + \Log::debug('------- [异步通知]费用代发 - 申请代发 - 错误 -----',$e->getMessage()); + } + + return false; + } + + +} \ No newline at end of file diff --git a/plugins/use-staff/src/models/ExternalApi.php b/plugins/use-staff/src/models/ExternalApi.php new file mode 100644 index 00000000..9a47faa7 --- /dev/null +++ b/plugins/use-staff/src/models/ExternalApi.php @@ -0,0 +1,341 @@ +getSign($params); + // 发起请求 + $data = [ + 'jsonStr' => json_encode($params,JSON_UNESCAPED_UNICODE), + 'sign' => $sign, + ]; + $header = [ + 'Content-Type: application/json; charset=utf-8', + 'Cache-Control: no-cache', + 'Pragma: no-cache' + ]; + $result = curlPost($this->apiLink.$api,$data,30,$header,'json'); + $result['jsonStr'] = json_decode($result['jsonStr'],true); + + return $result['jsonStr']; + }catch(\Exception $e){ + \Log::debug('------- 灵活务工 - 接口请求 - 失败原因 -----',$e->getMessage()); + return $e->getMessage(); + } + } + /** + * Common: 发起请求 - 获取签名 + * Author: wu-hui + * Time: 2023/10/08 14:41 + * @param $params + * @return false|string + */ + private function getSign($params){ + // 按照 key 的 ASCII 字符串顺序升序排列 + ksort($params); + // 获取签名字符串 + $signStr = ''; + foreach($params as $key => $val){ + $signStr .= is_array($val) ? json_encode($val) : $val; + } + + // 获取签名 + return hash_hmac("sha256",$signStr,$this->accessSecret); + } + /** + * Common: 根据方法名称 返回回调地址 + * Author: wu-hui + * Time: 2023/10/09 11:24 + * @param $funName + * @return string + * @throws Exception + */ + private function getNotifyUrl($funName){ + // 异步通知地址前缀 + $domainName = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http"; + $domainName .= "://" . $_SERVER['HTTP_HOST']; + $uniacid = \YunShop::app()->uniacid; + + // 回调地址长度不能超过100 + $notifyUrl = $domainName."/addons/yun_shop/api.php?i={$uniacid}&route=plugin.use-staff.api.notify.".$funName; + if(strlen($notifyUrl) > 100) throw new \Exception('异步通知地址长度超出限制,请联系管理员处理'); + return $notifyUrl; + } + + + /** + * Common: 员工入驻 - 申请入驻 + * Author: wu-hui + * Time: 2023/10/08 16:58 + * @param $info + * @return mixed|void + * @throws Exception + */ + public function personnelAccess($info){ + // 基本参数 + $params = [ + 'accessId' => $this->accessId,// [必填]接入ID + 'orderId' => createNo('YCH',6,TRUE),// [必填]请求流水号 + 'coreAgentId' => $this->coreAgentId,// [必填]核心企业机构号 + 'groundAgentId' => $this->groundAgentId,// [必填]落地公司机构号 + 'noticeUrl' => $this->getNotifyUrl('access'),// [必填]异步通知地址 + 'name' => $info['name'],// [必填]账户名称 + // 'jobNum' => '',// [选填]工号 + 'contactTelNo' => $info['tel'],// [必填]手机号 + // 'bankProvId' => '510000',// [必填]银行所在省 + // 'bankCityId' => '510100',// [必填]银行所在市 + 'cardType' => $info['card_type'],// [必填]卡类型(1-对私/2-对公) + // 'bankName' => '',// [选填]银行名称 + 'bankSubName' => $info['bank_sub_name'] ?? '',// [条件必填]开户银行支行名称,卡类型为2-对公必填 + 'accountIdSdate' => $info['account_id_start'],// [必填]证件有效期开始时间 + // 'accountIdEdate' => '20401107',// [选填]证件有效期终止时间,YYYYMMDD或长期 + 'bankActName' => $info['bank_act_name'],// [必填]卡号姓名 + 'cardNum' => $info['card_num'],// [必填]卡号 + 'accountIdNo' => $info['account_id'],// [必填]持卡人证件号 + 'accountIdType' => '1',// [选填]证件类型(1.身份证 9.其他类型)不填默认1 + 'merType' => $info['mer_type'],// [必填]商户类型 (1-个体户/3-个人) + // 'merName' => '',// [条件必填]商户注册名称 + // 'merShortName' => '',// [条件必填]商户简称 + // 'provId' => '',// [条件必填]商户经营所在省 + // 'cityId' => '',// [条件必填]商户经营所在市 + // 'areaId' => '',// [条件必填]商户经营所在区县 + // 'merAddress' => '',// [条件必填]商户经营地址 + // 'businessCode' => '',// [条件必填]营业执照号 + // 'businessSdate' => '',// [条件必填]营业执照有效期开始日期 + // 'businessEdate' => '',// [条件必填]营业执照有效期结束日期,YYYYMMDD或长期 + ]; + // 发起请求 + $result = $this->requestApi('/api/personnel/personnelAccess',$params); + $result['memberId'] = ''; + if((int)$result['respCode'] === 0) { + $params['uid'] = $info['uid']; + $params['memberId'] = $result['memberId']; + $params['trans_seq_id'] = $result['transSeqId']; + $params['status'] = $result['state']; + // 判断:当前用户是否已经存在账号信息 + $isHas = (int)UseStaff::uniacid()->where('uid',$info['uid'])->value('id'); + if($isHas > 0) (new UseStaff())->updateRecord($params); + else (new UseStaff())->addRecord($params); + + return $result; + }else throw new Exception($result['respDesc']); + } + /** + * Common: 员工入驻 - 入驻结果查询 + * Author: wu-hui + * Time: 2023/10/08 17:02 + * @param $memberId + * @param $transSeqId + * @return mixed|void + * @throws Exception + */ + public function personnelResult($memberId = '',$transSeqId = ''){ + // 基本参数 + $params = [ + 'accessId' => $this->accessId,// [必填]接入ID + 'transSeqId' => $transSeqId,// [选填]系统流水号 + 'memberId' => $memberId,// [选填]会员号 + ]; + // 发起请求 + $result = $this->requestApi('/api/personnel/queryPersonnel',$params); + if((int)$result['respCode'] === 0) { + UseStaff::uniacid()->where('member_id',$memberId)->update([ + 'status' => $result['state'], + 'member_id' => $result['memberId'] + ]); + + return $result; + }else throw new Exception($result['respDesc']); + } + /** + * Common: 员工签约 + * Author: wu-hui + * Time: 2023/10/08 17:46 + * @param $uid + * @return mixed|void + * @throws Exception + */ + public function personalContractCreate($uid){ + // 获取员工信息 + $staff = UseStaff::getSingleInfo(['uid'=>$uid]); + // 基本参数 + $params = [ + 'accessId' => $this->accessId,// [必填]接入ID + 'orderId' => createNo('YCH',4,TRUE),// [必填]请求流水号 + 'coreAgentId' => $this->coreAgentId,// [必填]核心企业机构号 + 'groundAgentId' => $this->groundAgentId,// [必填]落地公司机构号 + 'memberId' => $staff['member_id'],// [必填]个人会员号 + 'signResultViewUrl' => '',// [选填]签约结果提示显示页面 + ]; + // 发起请求 + $result = $this->requestApi('/api/contract/personalContractCreate',$params); + if((int)$result['respCode'] === 0) { + UseStaff::uniacid()->where('member_id',$staff['member_id'])->update([ + 'signing_status' => $result['signState'], + 'contract_id' => $result['contractId'], + 'contract_name' => $result['contractName'], + ]); + + return $result; + }else throw new Exception($result['respDesc']); + } + /** + * Common: 员工签约 - 签约结果查询 + * Author: wu-hui + * Time: 2023/10/08 17:50 + * @param $memberId + * @return mixed|void + * @throws Exception + */ + public function personalContractQuery($memberId){ + // 获取员工信息 + $staff = UseStaff::getSingleInfo(['member_id'=>$memberId]); + // 基本参数 + $params = [ + 'accessId' => $this->accessId,// [必填]接入ID + 'orderId' => createNo('YCH',6,TRUE),// [必填]请求流水号 + 'contractId' => $staff['contract_id'],// [必填]核心企业机构号 + ]; + // 发起请求 + $result = $this->requestApi('/api/contract/personalContractQuery',$params); + if((int)$result['respCode'] === 0) { + UseStaff::uniacid()->where('member_id',$staff['member_id'])->update([ + 'signing_status' => $result['signState'], + ]); + + return $result; + }else throw new Exception($result['respDesc']); + } + /** + * Common: 费用代发 - 申请代发 + * Author: wu-hui + * Time: 2023/10/09 10:15 + * @param $info + * @return mixed|void + * @throws Exception + */ + public function salaryModelOutOrder($info){ + // 获取员工信息 + $staff = UseStaff::getSingleInfo($info); + // 基本参数 + $orderNo = createNo('YCH',6,TRUE); + $params = [ + 'accessId' => $this->accessId,// [必填]接入ID + 'orderId' => $orderNo,// [必填]请求流水号 + 'agentId' => $this->coreAgentId,// [必填]核心企业机构号 + 'bmemberId' => $this->bmemberId,// [必填]落地公司商户号,落地公司memberId + 'salaryModle' => '1',// [必填]代发模式,1-普票 2-专票 + 'accountModle' => '2',// [必填]走账模式,2-代发 + 'modeIdcompany' => '1',// [必填]走账类型,1-单账户模式 + 'noticeUrl' => $this->getNotifyUrl('salary'),// [必填]异步通知地址 + // [必填]代发费用明细 + 'batchSalaryOutOrderModleDtos' => [[ + 'memberId' => $staff['member_id'],// [必填]会员号 + 'outOrderId' => $orderNo,// [必填]外部订单号 + 'salary' => $info['salary'],// [必填]费用金额 + 'salaryMonth' => $info['month'],// [必填]月份,格式:YYYYMM + ]], + ]; + // 发起请求 + $result = $this->requestApi('/api/salaryInfo/salaryModleOutOrder',$params); + if((int)$result['respCode'] === 2) { + $time = time(); + UseStaffSalary::insert([ + 'uniacid' => \YunShop::app()->uniacid, + 'uid' => $info['uid'], + 'order_no' => $orderNo, + 'member_id' => $staff['member_id'], + 'salary' => $info['salary'], + 'salary_month' => $info['month'], + 'attach_id' => $result['attachId'], + 'created_at' => $time, + 'updated_at' => $time, + ]); + + return $result; + }else throw new Exception($result['respDesc']); + } + /** + * Common: 费用代发 - 结果查询 + * Author: wu-hui + * Time: 2023/10/09 10:51 + * @param $attachId + * @return mixed|void + * @throws Exception + */ + public function salaryOutOrderResult($attachId){ + // 基本参数 + $params = [ + 'accessId' => $this->accessId,// [必填]接入ID + 'memberId' => $this->memberId,// [必填]智汇管家代理商会员号 + 'attachId' => $attachId,// [条件必填]若订单号未填,则批次号必填 + // 'orderId' => $this->accessId,// [条件必填]若批次号未填,则订单号必填 + ]; + // 发起请求 + $result = $this->requestApi('/api/queryresult/salaryOutOrderResult',$params); + if((int)$result['respCode'] === 0) { + $salaryOutOrderRespDto = $result['salaryOutOrderRespDto']; + $first = collect($salaryOutOrderRespDto)->first(); + UseStaffSalary::where('attach_id',$attachId) + ->update([ + 'attach_state' => $result['attachState'], + 'order_amt' => $first['orderAmt'], + 'real_trans_amt' => $first['realTransAmt'], + 'out_member_id' => $first['outMemberId'], + 'salary_state' => $first['salaryState'], + 'trans_fee' => $first['transFee'], + ]); + + return $result; + }else throw new Exception($result['respDesc']); + + } + + + + + +} \ No newline at end of file diff --git a/plugins/use-staff/src/models/UseStaff.php b/plugins/use-staff/src/models/UseStaff.php new file mode 100644 index 00000000..9770ed32 --- /dev/null +++ b/plugins/use-staff/src/models/UseStaff.php @@ -0,0 +1,152 @@ + 'datetime:Y-m-d H:i', + 'card_type' => 'string', + 'mer_type' => 'string', + ]; + /** + * Common: 添加入驻记录 + * Author: wu-hui + * Time: 2023/10/08 16:39 + * @param $params + * @throws \Exception + */ + public function addRecord($params){ + // 判断:是否已经存在 + $isHas = (int)self::uniacid()->where('card_num',$params['cardNum'])->value('id'); + if($isHas > 0) throw new \Exception('当前银行卡账号已经存在,请勿重复添加!'); + // 添加存在 + $time = time(); + $data = [ + 'uniacid' => \YunShop::app()->uniacid, + 'uid' => $params['uid'], + 'order_id' => $params['orderId'], + 'name' => $params['name'], + 'tel' => $params['contactTelNo'], + 'card_type' => $params['cardType'], + 'account_id_start' => $params['accountIdSdate'], + 'bank_act_name' => $params['bankActName'], + 'card_num' => $params['cardNum'], + 'account_id' => $params['accountIdNo'], + 'mer_type' => $params['merType'], + 'member_id' => $params['memberId'], + 'status' => $params['status'], + 'created_at' => $time, + 'updated_at' => $time, + 'trans_seq_id' => $params['trans_seq_id'], + ]; + + self::insert($data); + } + /** + * Common: 修改入驻记录 + * Author: wu-hui + * Time: 2023/10/10 12:01 + * @param $params + */ + public function updateRecord($params){ + self::uniacid()->where('uid',$params['uid'])->update([ + 'order_id' => $params['orderId'], + 'name' => $params['name'], + 'tel' => $params['contactTelNo'], + 'card_type' => $params['cardType'], + 'account_id_start' => $params['accountIdSdate'], + 'bank_act_name' => $params['bankActName'], + 'card_num' => $params['cardNum'], + 'account_id' => $params['accountIdNo'], + 'mer_type' => $params['merType'], + 'member_id' => $params['memberId'], + 'status' => $params['status'], + 'updated_at' => time(), + 'trans_seq_id' => $params['trans_seq_id'], + ]); + } + /** + * Common: 获取一条信息(支持刷新信息然后返回) + * Author: wu-hui + * Time: 2023/10/10 11:40 + * @param $params + * @param string $field + * @param false $isAllowRefresh + * @return array + * @throws \Exception + */ + public static function getSingleInfo($params,$field = '*',$isAllowRefresh = false){ + // 条件 + $where = []; + if((int)$params['member_id'] > 0) $where[] = ['member_id','=',(int)$params['member_id']]; + else if((int)$params['uid'] > 0) $where[] = ['uid','=',(int)$params['uid']]; + else if(!empty($params['order_id'])) $where[] = ['order_id','=',(int)$params['order_id']]; + else throw new \Exception("参数错误,必要参数至少存在一个!"); + // 获取信息 + $info = self::uniacid() + ->select($field) + ->where($where) + ->first(); + $info = $info ? $info->toArray() : []; + // 判断:是否执行一次刷新 入驻状态:1=待开户,2=开户成功待签约,3=开户失败,4=签约成功,5=签约失败 + if(array_key_exists('status',$info) && (array_key_exists('member_id',$info) || array_key_exists('trans_seq_id',$info)) && $isAllowRefresh){ + if(in_array($info['status'],[1,2])){ + (new ExternalApi())->personnelResult($info['member_id'],$info['trans_seq_id']); + + return self::getSingleInfo($params,$field,false); + } + } + + return $info; + } + /** + * Common: 获取员工账号列表 + * Author: wu-hui + * Time: 2023/10/09 13:41 + * @param $pageSize + * @param $search + * @param string[] $field + * @return array + */ + public function getList($pageSize,$search,$field = ['*']){ + // 条件生成 + $where = []; + if($search['name']) $where[] = ['name','like',"%{$search['name']}%"]; + if($search['tel']) $where[] = ['tel','=',$search['tel']]; + if((int)$search['card_type'] > 0) $where[] = ['card_type','=',$search['card_type']]; + if($search['bank_act_name']) $where[] = ['bank_act_name','like',"%{$search['bank_act_name']}%"]; + if((int)$search['mer_type'] > 0) $where[] = ['mer_type','=',$search['mer_type']]; + if((int)$search['status'] > 0) $where[] = ['status','=',$search['status']]; + // 列表获取 + $list = self::uniacid() + ->select($field) + ->where($where) + ->with([ + 'member' => function($query){ + $query->select(['uid','nickname','realname','avatar']); + }, + ]) + ->orderBy('created_at','DESC') + ->orderBy('id','DESC') + ->paginate($pageSize); + + return $list ? $list->toArray() : []; + } + + + /** + * Common: 一对一关联 用户信息 + * Author: wu-hui + * Time: 2023/10/09 13:40 + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function member(){ + return $this->hasOne(Member::class,'uid','uid'); + } +} \ No newline at end of file diff --git a/plugins/use-staff/src/models/UseStaffSalary.php b/plugins/use-staff/src/models/UseStaffSalary.php new file mode 100644 index 00000000..003aa631 --- /dev/null +++ b/plugins/use-staff/src/models/UseStaffSalary.php @@ -0,0 +1,55 @@ + 'datetime' + ]; + /** + * Common: 获取打款记录列表 + * Author: wu-hui + * Time: 2023/10/09 14:50 + * @param $pageSize + * @param $search + * @param string[] $field + * @return array + */ + public function getList($pageSize,$search,$field = ['*']){ + // 条件生成 + $where = []; + if($search['uid']) $where[] = ['uid','=',$search['uid']]; + if((int)$search['attach_state'] > 0) $where[] = ['attach_state','=',$search['attach_state']]; + // 列表获取 + $list = self::uniacid() + ->select($field) + ->where($where) + ->with([ + 'member' => function($query){ + $query->select(['uid','nickname','realname','avatar']); + }, + ]) + ->orderBy('created_at','DESC') + ->orderBy('id','DESC') + ->paginate($pageSize); + + return $list ? $list->toArray() : []; + } + + + /** + * Common: 一对一关联 用户信息 + * Author: wu-hui + * Time: 2023/10/09 13:40 + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function member(){ + return $this->hasOne(Member::class,'uid','uid'); + } +} \ No newline at end of file diff --git a/plugins/use-staff/views/admin/index/index.blade.php b/plugins/use-staff/views/admin/index/index.blade.php new file mode 100644 index 00000000..c213b3c4 --- /dev/null +++ b/plugins/use-staff/views/admin/index/index.blade.php @@ -0,0 +1,160 @@ +@extends('layouts.base') + +@section('content') +
| ID | +用户信息 | +账号信息 | +银行卡信息 | +状态 | +入驻时间 | +操作 | +
|---|---|---|---|---|---|---|
| {{ $item['id'] }} | +
+
+
+
+
+
+ |
+
+
+ 账号名称:{{ $item['name'] }}
+ + 联系电话:{{ $item['tel'] }} + |
+
+
+ 持有人姓名:{{ $item['bank_act_name'] }}
+ + 卡号:{{ $item['card_num'] }} + 类型:{{ $item['card_type'] == 1 ? '对私' : '对公' }} + |
+ + @switch($item['status']) + @case(1)待开户@break + @case(2)开户成功待签约@break + @case(3)开户失败@break + @case(4)签约成功@break + @case(5)签约失败@break + @endswitch + | +{{ $item['created_at'] }} | ++ + + + | +
| ID | +用户信息 | +申请提现信息 | +打款信息 | +状态 | +申请时间 | +操作 | +
|---|---|---|---|---|---|---|
| {{ $item['id'] }} | +
+
+
+
+
+
+ |
+
+
+ 批次号:{{ $item['attach_id'] }}
+ + 提现金额:{{ $item['salary'] }} + |
+
+
+ 实际打款金额:{{ $item['real_trans_amt'] }}
+ + 转账服务费:{{ $item['trans_fee'] }} + |
+ + {{--状态:1=代发处理中,2=代发处理成功,3=代发部分处理成功,4=代发处理失败--}} + @switch($item['attach_state']) + @case(1)处理中@break + @case(2)处理成功@break + @case(3)部分处理成功@break + @case(4)处理失败@break + @endswitch + | +{{ $item['created_at'] }} | ++ + + + | +