diff --git a/addons/shopro_huifu/application/admin/controller/shopro_huifu/Onboard.php b/addons/shopro_huifu/application/admin/controller/shopro_huifu/Onboard.php
index bdd4324..b128ba4 100644
--- a/addons/shopro_huifu/application/admin/controller/shopro_huifu/Onboard.php
+++ b/addons/shopro_huifu/application/admin/controller/shopro_huifu/Onboard.php
@@ -2,7 +2,10 @@
namespace app\admin\controller\shopro_huifu;
+use addons\shopro_huifu\library\onboard\HuifuOnboardAdminService;
use addons\shopro_huifu\library\onboard\HuifuOnboardAdminView;
+use addons\shopro_huifu\library\onboard\HuifuOnboardBankBranch;
+use addons\shopro_huifu\library\onboard\HuifuOnboardError;
use addons\shopro_huifu\library\onboard\HuifuOnboardQuery;
use addons\shopro_huifu\library\onboard\HuifuOnboardService;
use addons\shopro_huifu\model\Onboard as OnboardModel;
@@ -10,6 +13,8 @@ use app\admin\controller\shopro\Base;
class Onboard extends Base
{
+ protected $noNeedRight = ['userRoles', 'searchBranch'];
+
public function index()
{
if ($this->request->isAjax()) {
@@ -74,6 +79,78 @@ class Onboard extends Base
}
}
+ public function add()
+ {
+ if ($this->request->isPost()) {
+ return $this->persistDraft();
+ }
+ return $this->view->fetch();
+ }
+
+ public function edit($ids = null)
+ {
+ $row = OnboardModel::get($ids);
+ if (!$row) {
+ $this->error('记录不存在');
+ }
+ if ($this->request->isPost()) {
+ return $this->persistDraft($row);
+ }
+ $this->assignconfig('onboardForm', HuifuOnboardAdminView::formDataFromRow($row));
+ return $this->view->fetch('shopro_huifu/onboard/add');
+ }
+
+ public function userRoles()
+ {
+ $userId = intval($this->request->get('user_id', 0));
+ if ($userId <= 0) {
+ $this->error('请选择用户');
+ }
+ $user = HuifuOnboardAdminView::enrichListRow(['user_id' => $userId, 'payload' => '']);
+ $this->success('ok', null, [
+ 'user' => [
+ 'id' => $userId,
+ 'nickname' => $user['user_nickname'] ?? '',
+ 'mobile' => $user['user_mobile'] ?? '',
+ ],
+ 'roles' => HuifuOnboardAdminView::listRolesForUser($userId),
+ ]);
+ }
+
+ public function searchBranch()
+ {
+ $keyword = trim((string) $this->request->get('keyword', ''));
+ $areaId = trim((string) $this->request->get('area_id', ''));
+ $this->success('ok', null, HuifuOnboardBankBranch::search($keyword, $areaId, 20));
+ }
+
+ protected function persistDraft($row = null)
+ {
+ $userId = intval($this->request->post('user_id', 0));
+ $roleType = trim((string) $this->request->post('role_type', ''));
+ $roleRefId = intval($this->request->post('role_ref_id', 0));
+ $form = $this->request->post('form/a', []);
+ if ($row) {
+ $userId = intval($row['user_id']);
+ $roleType = $row['role_type'];
+ $roleRefId = intval($row['role_ref_id']);
+ }
+ if (!$form || !is_array($form)) {
+ $this->error('请填写进件资料');
+ }
+ try {
+ $service = new HuifuOnboardAdminService();
+ $saved = $service->saveDraft($userId, $roleType, $roleRefId, $form);
+ $this->success('进件资料已保存,状态为待后台审核', null, [
+ 'id' => $saved ? $saved['id'] : 0,
+ ]);
+ } catch (\InvalidArgumentException $e) {
+ $this->error($e->getMessage());
+ } catch (\Throwable $e) {
+ $this->error(HuifuOnboardError::translate($e->getMessage()));
+ }
+ }
+
public function retry($ids = null)
{
$row = OnboardModel::get($ids);
diff --git a/addons/shopro_huifu/application/admin/view/shopro_huifu/onboard/add.html b/addons/shopro_huifu/application/admin/view/shopro_huifu/onboard/add.html
new file mode 100644
index 0000000..18f46cd
--- /dev/null
+++ b/addons/shopro_huifu/application/admin/view/shopro_huifu/onboard/add.html
@@ -0,0 +1,180 @@
+
+
+
+
+
+
+ 用户与角色
+
+
+
+
+
+
+ {{ userLabel }}
+
+
+
+
+ {{ item.role_label }}
+ {{ item.disabled_reason || (item.onboard_status ? '已有记录:' + item.onboard_status : '新建') }}
+
+
+
+
+ {{ roleLabel }}
+
+
+ 账户类型
+
+
+ 个人
+ 个体户/企业
+
+
+
+
+ 对私
+ 对公
+
+
+
+
+ 身份实名信息
+
+
+
+
+
+
+
+
+ 长期有效
+ 有截止日期
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
![]()
+
点击上传
+
+
+
+
+
+
+
![]()
+
点击上传
+
+
+
+
+
+
+ 商户信息
+
+
+
+ 长期有截止
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 长期有截止
+
+
+
+
+
+
+
+
+
+
点击上传
+
+
+
+
+
点击上传
+
+
+
+
+
点击上传
+
+
+
+
+ 结算账户信息
+
+
+
+
+
+ 已选:{{ form.branch_name }}({{ form.branch_code }})
+
+
+
{{ item.branch_name }}
+
{{ item.branch_code }}
+
+
+
+
+
+
+
+
+
点击上传
+
+ 建议上传,可加快审核
+
+
+
+
点击上传
+
+
+
+
+ {{ isEdit ? '保存修改' : '保存进件资料' }}
+ 取消
+
+
+
diff --git a/addons/shopro_huifu/application/admin/view/shopro_huifu/onboard/index.html b/addons/shopro_huifu/application/admin/view/shopro_huifu/onboard/index.html
index af7e9be..3cf659b 100644
--- a/addons/shopro_huifu/application/admin/view/shopro_huifu/onboard/index.html
+++ b/addons/shopro_huifu/application/admin/view/shopro_huifu/onboard/index.html
@@ -33,6 +33,7 @@
+ 新建进件
刷新列表
@@ -55,9 +56,10 @@
{{ formatTime(scope.row.updatetime) }}
-
+
查看资料
+ 编辑
提交汇付
刷新
重提
@@ -133,6 +135,7 @@
关闭
+ 编辑资料
提交汇付
刷新状态
重新提交
diff --git a/addons/shopro_huifu/config/menu.php b/addons/shopro_huifu/config/menu.php
index c2f1114..518e54b 100644
--- a/addons/shopro_huifu/config/menu.php
+++ b/addons/shopro_huifu/config/menu.php
@@ -25,6 +25,10 @@ return [
'weigh' => 4,
'sublist' => [
['type' => 'file', 'name' => 'shopro_huifu/onboard/index', 'title' => '查看', 'ismenu' => 0],
+ ['type' => 'file', 'name' => 'shopro_huifu/onboard/add', 'title' => '新建进件', 'ismenu' => 0],
+ ['type' => 'file', 'name' => 'shopro_huifu/onboard/edit', 'title' => '编辑进件', 'ismenu' => 0],
+ ['type' => 'file', 'name' => 'shopro_huifu/onboard/userRoles', 'title' => '用户角色', 'ismenu' => 0],
+ ['type' => 'file', 'name' => 'shopro_huifu/onboard/searchBranch', 'title' => '搜索支行', 'ismenu' => 0],
['type' => 'file', 'name' => 'shopro_huifu/onboard/detail', 'title' => '查看资料', 'ismenu' => 0],
['type' => 'file', 'name' => 'shopro_huifu/onboard/poll', 'title' => '刷新状态', 'ismenu' => 0],
['type' => 'file', 'name' => 'shopro_huifu/onboard/submit', 'title' => '提交汇付', 'ismenu' => 0],
diff --git a/addons/shopro_huifu/library/onboard/HuifuOnboardAdminService.php b/addons/shopro_huifu/library/onboard/HuifuOnboardAdminService.php
new file mode 100644
index 0000000..03121fc
--- /dev/null
+++ b/addons/shopro_huifu/library/onboard/HuifuOnboardAdminService.php
@@ -0,0 +1,47 @@
+assertRoleBinding($userId, $roleType, $roleRefId);
+
+ $service = new HuifuOnboardService();
+ return $service->saveDraft($userId, $roleType, $roleRefId, $formData);
+ }
+
+ protected function assertRoleBinding($userId, $roleType, $roleRefId)
+ {
+ if ($roleType === 'promoter') {
+ if ($roleRefId !== $userId) {
+ throw new \InvalidArgumentException('分销商角色参数无效');
+ }
+ $agent = Db::name('shopro_commission_agent')->where('user_id', $userId)->find();
+ if (!$agent) {
+ throw new \InvalidArgumentException('该用户不是分销商,无法创建分销商进件');
+ }
+ return;
+ }
+
+ $agent = Db::name('shopro_regional_agent')
+ ->where('id', $roleRefId)
+ ->where('user_id', $userId)
+ ->find();
+ if (!$agent) {
+ throw new \InvalidArgumentException('区域公司与用户不匹配');
+ }
+ }
+}
diff --git a/addons/shopro_huifu/library/onboard/HuifuOnboardAdminView.php b/addons/shopro_huifu/library/onboard/HuifuOnboardAdminView.php
index 8933cb2..fa27a94 100644
--- a/addons/shopro_huifu/library/onboard/HuifuOnboardAdminView.php
+++ b/addons/shopro_huifu/library/onboard/HuifuOnboardAdminView.php
@@ -206,4 +206,140 @@ class HuifuOnboardAdminView
}
return substr($value, 0, 4) . '-' . substr($value, 4, 2) . '-' . substr($value, 6, 2);
}
+
+ /**
+ * 后台新建/编辑进件:列出用户可绑定的角色
+ */
+ public static function listRolesForUser($userId)
+ {
+ $userId = intval($userId);
+ if ($userId <= 0) {
+ return [];
+ }
+ $roles = [];
+ $commissionAgent = Db::name('shopro_commission_agent')->where('user_id', $userId)->find();
+ if ($commissionAgent) {
+ $row = \addons\shopro_huifu\model\Onboard::findByRole($userId, 'promoter', $userId);
+ $roles[] = self::buildRoleOption(
+ 'promoter',
+ $userId,
+ '分销商',
+ $commissionAgent['status'] ?? '',
+ $row
+ );
+ }
+ $regionalAgents = Db::name('shopro_regional_agent')->where('user_id', $userId)->order('id desc')->select();
+ foreach ($regionalAgents as $agent) {
+ $row = \addons\shopro_huifu\model\Onboard::findByRole($userId, 'regional_agent', $agent['id']);
+ $label = '区域公司';
+ if (!empty($agent['area_name'])) {
+ $label .= '(' . $agent['area_name'] . ')';
+ }
+ $roles[] = self::buildRoleOption(
+ 'regional_agent',
+ $agent['id'],
+ $label,
+ $agent['status'] ?? '',
+ $row
+ );
+ }
+ return $roles;
+ }
+
+ protected static function buildRoleOption($roleType, $roleRefId, $label, $agentStatus, $onboardRow)
+ {
+ $onboardStatus = $onboardRow ? ($onboardRow['onboard_status'] ?? '') : '';
+ $blocked = $onboardRow && in_array($onboardStatus, [
+ \addons\shopro_huifu\model\Onboard::STATUS_SUBMITTING,
+ \addons\shopro_huifu\model\Onboard::STATUS_BASIC_OK,
+ \addons\shopro_huifu\model\Onboard::STATUS_BUSI_PENDING,
+ \addons\shopro_huifu\model\Onboard::STATUS_APPROVED,
+ ], true);
+ return [
+ 'role_type' => $roleType,
+ 'role_ref_id' => $roleRefId,
+ 'role_label' => $label,
+ 'agent_status' => $agentStatus,
+ 'onboard_id' => $onboardRow ? intval($onboardRow['id']) : 0,
+ 'onboard_status' => $onboardStatus ?: null,
+ 'can_save' => !$blocked,
+ 'disabled_reason' => $blocked ? '该角色进件处理中或已通过,不可新建/覆盖' : '',
+ ];
+ }
+
+ public static function defaultFormData()
+ {
+ return [
+ 'account_type' => 'indv',
+ 'bank_account_type' => '0',
+ 'name' => '',
+ 'cert_no' => '',
+ 'cert_validity_type' => '1',
+ 'cert_begin_date' => '',
+ 'cert_end_date' => '',
+ 'mobile_no' => '',
+ 'reg_detail' => '',
+ 'shopro_province_id' => '',
+ 'shopro_city_id' => '',
+ 'shopro_district_id' => '',
+ 'prov_id' => '',
+ 'area_id' => '',
+ 'district_id' => '',
+ 'card_no' => '',
+ 'card_name' => '',
+ 'branch_code' => '',
+ 'branch_name' => '',
+ 'mp' => '',
+ 'id_card_front_url' => '',
+ 'id_card_back_url' => '',
+ 'bank_card_url' => '',
+ 'reg_name' => '',
+ 'license_code' => '',
+ 'license_validity_type' => '1',
+ 'license_begin_date' => '',
+ 'license_end_date' => '',
+ 'legal_name' => '',
+ 'legal_mobile' => '',
+ 'legal_cert_no' => '',
+ 'legal_cert_validity_type' => '1',
+ 'legal_cert_begin_date' => '',
+ 'legal_cert_end_date' => '',
+ 'license_url' => '',
+ 'legal_id_front_url' => '',
+ 'legal_id_back_url' => '',
+ 'account_permit_url' => '',
+ ];
+ }
+
+ public static function formDataFromRow($row)
+ {
+ $data = is_array($row) ? $row : $row->toArray();
+ $payload = self::parsePayload($data['payload'] ?? '');
+ $form = array_merge(self::defaultFormData(), $payload);
+ foreach (['id_card_front_url', 'id_card_back_url', 'bank_card_url', 'license_url', 'legal_id_front_url', 'legal_id_back_url', 'account_permit_url'] as $field) {
+ if (!empty($form[$field])) {
+ $form[$field] = self::fullUrl($form[$field]);
+ }
+ }
+ $user = self::fetchUser($data['user_id'] ?? 0);
+ $roles = self::listRolesForUser($data['user_id'] ?? 0);
+ $roleLabel = '';
+ foreach ($roles as $role) {
+ if ($role['role_type'] === ($data['role_type'] ?? '') && intval($role['role_ref_id']) === intval($data['role_ref_id'] ?? 0)) {
+ $roleLabel = $role['role_label'];
+ break;
+ }
+ }
+
+ return [
+ 'onboard_id' => intval($data['id'] ?? 0),
+ 'user_id' => intval($data['user_id'] ?? 0),
+ 'user_label' => trim(($user['nickname'] ?? '') . ' (' . ($user['mobile'] ?? $data['user_id']) . ')'),
+ 'role_type' => $data['role_type'] ?? '',
+ 'role_ref_id' => intval($data['role_ref_id'] ?? 0),
+ 'role_label' => $roleLabel,
+ 'onboard_status' => $data['onboard_status'] ?? '',
+ 'form' => $form,
+ ];
+ }
}
diff --git a/addons/shopro_huifu/public/assets/js/backend/shopro_huifu/onboard.js b/addons/shopro_huifu/public/assets/js/backend/shopro_huifu/onboard.js
index 0fa11e8..86f7735 100644
--- a/addons/shopro_huifu/public/assets/js/backend/shopro_huifu/onboard.js
+++ b/addons/shopro_huifu/public/assets/js/backend/shopro_huifu/onboard.js
@@ -1,5 +1,8 @@
define(['jquery', 'bootstrap', 'backend'], function ($, undefined, Backend) {
+ var areaCache = null;
+ var branchTimer = null;
+
function withVue(callback) {
if (typeof Vue !== 'undefined') {
callback(Vue);
@@ -22,6 +25,262 @@ define(['jquery', 'bootstrap', 'backend'], function ($, undefined, Backend) {
});
}
+ function defaultForm() {
+ return {
+ account_type: 'indv',
+ bank_account_type: '0',
+ name: '',
+ cert_no: '',
+ cert_validity_type: '1',
+ cert_begin_date: '',
+ cert_end_date: '',
+ mobile_no: '',
+ reg_detail: '',
+ shopro_province_id: '',
+ shopro_city_id: '',
+ shopro_district_id: '',
+ prov_id: '',
+ area_id: '',
+ district_id: '',
+ card_no: '',
+ card_name: '',
+ branch_code: '',
+ branch_name: '',
+ mp: '',
+ id_card_front_url: '',
+ id_card_back_url: '',
+ bank_card_url: '',
+ reg_name: '',
+ license_code: '',
+ license_validity_type: '1',
+ license_begin_date: '',
+ license_end_date: '',
+ legal_name: '',
+ legal_mobile: '',
+ legal_cert_no: '',
+ legal_cert_validity_type: '1',
+ legal_cert_begin_date: '',
+ legal_cert_end_date: '',
+ license_url: '',
+ legal_id_front_url: '',
+ legal_id_back_url: '',
+ account_permit_url: ''
+ };
+ }
+
+ function createFormMixin() {
+ return {
+ data: function () {
+ return {
+ isEdit: false,
+ editId: 0,
+ userId: '',
+ userLabel: '',
+ roleKey: '',
+ roleType: '',
+ roleRefId: 0,
+ roleLabel: '',
+ userOptions: [],
+ userLoading: false,
+ roleOptions: [],
+ form: defaultForm(),
+ regionPath: [],
+ areaOptions: [],
+ areaProps: { value: 'id', label: 'name', children: 'children' },
+ branchKeyword: '',
+ branchResults: [],
+ uploadUrl: Fast.api.fixurl('ajax/upload'),
+ saving: false
+ };
+ },
+ computed: {
+ bankMobile: {
+ get: function () {
+ return this.form.account_type === 'ent' ? this.form.legal_mobile : this.form.mobile_no;
+ },
+ set: function (val) {
+ if (this.form.account_type === 'ent') {
+ this.form.legal_mobile = val;
+ } else {
+ this.form.mobile_no = val;
+ }
+ this.form.mp = val;
+ }
+ }
+ },
+ mounted: function () {
+ this.loadAreaTree();
+ this.initFromConfig();
+ },
+ methods: {
+ initFromConfig: function () {
+ var init = (typeof Config !== 'undefined' && Config.onboardForm) ? Config.onboardForm : null;
+ if (!init) return;
+ this.isEdit = true;
+ this.editId = init.onboard_id || 0;
+ this.userId = init.user_id;
+ this.userLabel = init.user_label || '';
+ this.roleType = init.role_type;
+ this.roleRefId = init.role_ref_id;
+ this.roleKey = init.role_type + ':' + init.role_ref_id;
+ this.roleLabel = init.role_label || '';
+ this.form = Object.assign(defaultForm(), init.form || {});
+ this.branchKeyword = this.form.branch_name || '';
+ this.restoreRegionPath();
+ },
+ loadAreaTree: function () {
+ var vm = this;
+ var done = function (data) {
+ areaCache = data || [];
+ vm.areaOptions = areaCache;
+ vm.restoreRegionPath();
+ };
+ if (areaCache) {
+ done(areaCache);
+ return;
+ }
+ Fast.api.ajax({ url: 'shopro/area/getCascader', type: 'GET' }, function (ret, res) {
+ done(res.data || []);
+ return false;
+ });
+ },
+ restoreRegionPath: function () {
+ var ids = [];
+ if (this.form.shopro_province_id) ids.push(parseInt(this.form.shopro_province_id, 10));
+ if (this.form.shopro_city_id) ids.push(parseInt(this.form.shopro_city_id, 10));
+ if (this.form.shopro_district_id) ids.push(parseInt(this.form.shopro_district_id, 10));
+ this.regionPath = ids.filter(function (n) { return !!n; });
+ },
+ onRegionChange: function (val) {
+ val = val || [];
+ this.form.shopro_province_id = val[0] ? String(val[0]) : '';
+ this.form.shopro_city_id = val[1] ? String(val[1]) : '';
+ this.form.shopro_district_id = val[2] ? String(val[2]) : '';
+ this.form.prov_id = this.form.shopro_province_id;
+ this.form.area_id = this.form.shopro_city_id;
+ this.form.district_id = this.form.shopro_district_id;
+ },
+ searchUser: function (keyword) {
+ if (!keyword) return;
+ var vm = this;
+ vm.userLoading = true;
+ Fast.api.ajax({
+ url: 'shopro/user/user/index',
+ type: 'GET',
+ data: { offset: 0, limit: 20, searchWhere: keyword }
+ }, function (ret, res) {
+ vm.userOptions = (res.data && res.data.rows) || [];
+ vm.userLoading = false;
+ return false;
+ }, function () {
+ vm.userLoading = false;
+ });
+ },
+ onUserChange: function () {
+ var vm = this;
+ vm.roleKey = '';
+ vm.roleType = '';
+ vm.roleRefId = 0;
+ vm.roleOptions = [];
+ if (!vm.userId) return;
+ Fast.api.ajax({
+ url: 'shopro_huifu/onboard/userRoles',
+ type: 'GET',
+ data: { user_id: vm.userId }
+ }, function (ret, res) {
+ var data = res.data || {};
+ vm.roleOptions = data.roles || [];
+ if (data.user) {
+ vm.userLabel = (data.user.nickname || '') + ' (' + (data.user.mobile || data.user.id) + ')';
+ }
+ return false;
+ });
+ },
+ onRoleChange: function () {
+ var parts = String(this.roleKey || '').split(':');
+ this.roleType = parts[0] || '';
+ this.roleRefId = parseInt(parts[1] || '0', 10);
+ var role = this.roleOptions.find(function (item) {
+ return item.role_type === this.roleType && item.role_ref_id === this.roleRefId;
+ }.bind(this));
+ this.roleLabel = role ? role.role_label : '';
+ },
+ onBranchInput: function () {
+ var vm = this;
+ clearTimeout(branchTimer);
+ branchTimer = setTimeout(function () {
+ if (!vm.branchKeyword) {
+ vm.branchResults = [];
+ return;
+ }
+ Fast.api.ajax({
+ url: 'shopro_huifu/onboard/searchBranch',
+ type: 'GET',
+ data: {
+ keyword: vm.branchKeyword,
+ area_id: vm.form.area_id || vm.form.shopro_city_id
+ }
+ }, function (ret, res) {
+ vm.branchResults = res.data || [];
+ return false;
+ });
+ }, 300);
+ },
+ selectBranch: function (item) {
+ this.form.branch_code = item.branch_code;
+ this.form.branch_name = item.branch_name;
+ this.branchKeyword = item.branch_name;
+ this.branchResults = [];
+ if (item.prov_id) this.form.prov_id = item.prov_id;
+ if (item.area_id) this.form.area_id = item.area_id;
+ },
+ onUploadSuccess: function (field, res) {
+ if (res && res.code === 1 && res.data && res.data.url) {
+ this.form[field] = res.data.fullurl || res.data.url;
+ return;
+ }
+ this.$message.error((res && res.msg) || '上传失败');
+ },
+ closeForm: function () {
+ Fast.api.close();
+ },
+ submitForm: function () {
+ var vm = this;
+ if (!vm.isEdit) {
+ if (!vm.userId) {
+ Toastr.error('请选择用户');
+ return;
+ }
+ if (!vm.roleType || !vm.roleRefId) {
+ Toastr.error('请选择进件角色');
+ return;
+ }
+ }
+ vm.saving = true;
+ var url = vm.isEdit
+ ? ('shopro_huifu/onboard/edit/ids/' + vm.editId)
+ : 'shopro_huifu/onboard/add';
+ Fast.api.ajax({
+ url: url,
+ type: 'POST',
+ data: {
+ user_id: vm.userId,
+ role_type: vm.roleType,
+ role_ref_id: vm.roleRefId,
+ form: vm.form
+ }
+ }, function () {
+ vm.saving = false;
+ Fast.api.close();
+ return false;
+ }, function () {
+ vm.saving = false;
+ });
+ }
+ }
+ };
+ }
+
var Controller = {
index: function () {
withVue(function (Vue) {
@@ -49,6 +308,30 @@ define(['jquery', 'bootstrap', 'backend'], function ($, undefined, Backend) {
this.getList();
},
methods: {
+ openCreate: function () {
+ var vm = this;
+ Backend.api.open('shopro_huifu/onboard/add', '新建汇付进件', {
+ area: ['900px', '90%'],
+ callback: function () {
+ vm.getList();
+ }
+ });
+ },
+ openEdit: function (id) {
+ var vm = this;
+ Backend.api.open('shopro_huifu/onboard/edit/ids/' + id, '编辑汇付进件', {
+ area: ['900px', '90%'],
+ callback: function () {
+ vm.getList();
+ if (vm.detailVisible && vm.detailId === id) {
+ vm.openDetail(id);
+ }
+ }
+ });
+ },
+ canEditRow: function (row) {
+ return ['draft', 'failed', 'rejected'].indexOf(row.onboard_status) >= 0;
+ },
getList: function () {
var vm = this;
vm.loading = true;
@@ -131,6 +414,11 @@ define(['jquery', 'bootstrap', 'backend'], function ($, undefined, Backend) {
this.retryRow(this.detailId);
}
},
+ editFromDetail: function () {
+ if (this.detailId) {
+ this.openEdit(this.detailId);
+ }
+ },
statusText: function (status) {
var map = {
draft: '待后台审核',
@@ -155,6 +443,17 @@ define(['jquery', 'bootstrap', 'backend'], function ($, undefined, Backend) {
}
});
});
+ },
+ add: function () {
+ withVue(function (Vue) {
+ new Vue({
+ el: '#huifuOnboardAdd',
+ mixins: [createFormMixin()]
+ });
+ });
+ },
+ edit: function () {
+ Controller.add();
}
};
return Controller;
diff --git a/application/admin/controller/shopro_huifu/Onboard.php b/application/admin/controller/shopro_huifu/Onboard.php
index 5900c96..ea3d062 100644
--- a/application/admin/controller/shopro_huifu/Onboard.php
+++ b/application/admin/controller/shopro_huifu/Onboard.php
@@ -2,7 +2,10 @@
namespace app\admin\controller\shopro_huifu;
+use addons\shopro_huifu\library\onboard\HuifuOnboardAdminService;
use addons\shopro_huifu\library\onboard\HuifuOnboardAdminView;
+use addons\shopro_huifu\library\onboard\HuifuOnboardBankBranch;
+use addons\shopro_huifu\library\onboard\HuifuOnboardError;
use addons\shopro_huifu\library\onboard\HuifuOnboardQuery;
use addons\shopro_huifu\library\onboard\HuifuOnboardService;
use addons\shopro_huifu\model\Onboard as OnboardModel;
@@ -10,6 +13,7 @@ use app\admin\controller\shopro\Base;
class Onboard extends Base
{
+ protected $noNeedRight = ['userRoles', 'searchBranch'];
public function index()
{
if ($this->request->isAjax()) {
@@ -77,6 +81,78 @@ class Onboard extends Base
}
}
+ public function add()
+ {
+ if ($this->request->isPost()) {
+ return $this->persistDraft();
+ }
+ return $this->view->fetch();
+ }
+
+ public function edit($ids = null)
+ {
+ $row = OnboardModel::get($ids);
+ if (!$row) {
+ $this->error('记录不存在');
+ }
+ if ($this->request->isPost()) {
+ return $this->persistDraft($row);
+ }
+ $this->assignconfig('onboardForm', HuifuOnboardAdminView::formDataFromRow($row));
+ return $this->view->fetch('shopro_huifu/onboard/add');
+ }
+
+ public function userRoles()
+ {
+ $userId = intval($this->request->get('user_id', 0));
+ if ($userId <= 0) {
+ $this->error('请选择用户');
+ }
+ $user = HuifuOnboardAdminView::enrichListRow(['user_id' => $userId, 'payload' => '']);
+ $this->success('ok', null, [
+ 'user' => [
+ 'id' => $userId,
+ 'nickname' => $user['user_nickname'] ?? '',
+ 'mobile' => $user['user_mobile'] ?? '',
+ ],
+ 'roles' => HuifuOnboardAdminView::listRolesForUser($userId),
+ ]);
+ }
+
+ public function searchBranch()
+ {
+ $keyword = trim((string) $this->request->get('keyword', ''));
+ $areaId = trim((string) $this->request->get('area_id', ''));
+ $this->success('ok', null, HuifuOnboardBankBranch::search($keyword, $areaId, 20));
+ }
+
+ protected function persistDraft($row = null)
+ {
+ $userId = intval($this->request->post('user_id', 0));
+ $roleType = trim((string) $this->request->post('role_type', ''));
+ $roleRefId = intval($this->request->post('role_ref_id', 0));
+ $form = $this->request->post('form/a', []);
+ if ($row) {
+ $userId = intval($row['user_id']);
+ $roleType = $row['role_type'];
+ $roleRefId = intval($row['role_ref_id']);
+ }
+ if (!$form || !is_array($form)) {
+ $this->error('请填写进件资料');
+ }
+ try {
+ $service = new HuifuOnboardAdminService();
+ $saved = $service->saveDraft($userId, $roleType, $roleRefId, $form);
+ $this->success('进件资料已保存,状态为待后台审核', null, [
+ 'id' => $saved ? $saved['id'] : 0,
+ ]);
+ } catch (\InvalidArgumentException $e) {
+ $this->error($e->getMessage());
+ } catch (\Throwable $e) {
+ $this->error(HuifuOnboardError::translate($e->getMessage()));
+ }
+ }
+
public function retry($ids = null)
{
$row = OnboardModel::get($ids);
diff --git a/application/admin/view/shopro_huifu/onboard/add.html b/application/admin/view/shopro_huifu/onboard/add.html
new file mode 100644
index 0000000..18f46cd
--- /dev/null
+++ b/application/admin/view/shopro_huifu/onboard/add.html
@@ -0,0 +1,180 @@
+
+
+
+
+
+
+ 用户与角色
+
+
+
+
+
+
+ {{ userLabel }}
+
+
+
+
+ {{ item.role_label }}
+ {{ item.disabled_reason || (item.onboard_status ? '已有记录:' + item.onboard_status : '新建') }}
+
+
+
+
+ {{ roleLabel }}
+
+
+ 账户类型
+
+
+ 个人
+ 个体户/企业
+
+
+
+
+ 对私
+ 对公
+
+
+
+
+ 身份实名信息
+
+
+
+
+
+
+
+
+ 长期有效
+ 有截止日期
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
![]()
+
点击上传
+
+
+
+
+
+
+
![]()
+
点击上传
+
+
+
+
+
+
+ 商户信息
+
+
+
+ 长期有截止
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 长期有截止
+
+
+
+
+
+
+
+
+
+
点击上传
+
+
+
+
+
点击上传
+
+
+
+
+
点击上传
+
+
+
+
+ 结算账户信息
+
+
+
+
+
+ 已选:{{ form.branch_name }}({{ form.branch_code }})
+
+
+
{{ item.branch_name }}
+
{{ item.branch_code }}
+
+
+
+
+
+
+
+
+
点击上传
+
+ 建议上传,可加快审核
+
+
+
+
点击上传
+
+
+
+
+ {{ isEdit ? '保存修改' : '保存进件资料' }}
+ 取消
+
+
+
diff --git a/application/admin/view/shopro_huifu/onboard/index.html b/application/admin/view/shopro_huifu/onboard/index.html
index af7e9be..3cf659b 100644
--- a/application/admin/view/shopro_huifu/onboard/index.html
+++ b/application/admin/view/shopro_huifu/onboard/index.html
@@ -33,6 +33,7 @@
+ 新建进件
刷新列表
@@ -55,9 +56,10 @@
{{ formatTime(scope.row.updatetime) }}
-
+
查看资料
+ 编辑
提交汇付
刷新
重提
@@ -133,6 +135,7 @@
关闭
+ 编辑资料
提交汇付
刷新状态
重新提交
diff --git a/public/assets/js/backend/shopro_huifu/onboard.js b/public/assets/js/backend/shopro_huifu/onboard.js
index 3022e3b..86f7735 100644
--- a/public/assets/js/backend/shopro_huifu/onboard.js
+++ b/public/assets/js/backend/shopro_huifu/onboard.js
@@ -1,5 +1,8 @@
define(['jquery', 'bootstrap', 'backend'], function ($, undefined, Backend) {
+ var areaCache = null;
+ var branchTimer = null;
+
function withVue(callback) {
if (typeof Vue !== 'undefined') {
callback(Vue);
@@ -22,6 +25,262 @@ define(['jquery', 'bootstrap', 'backend'], function ($, undefined, Backend) {
});
}
+ function defaultForm() {
+ return {
+ account_type: 'indv',
+ bank_account_type: '0',
+ name: '',
+ cert_no: '',
+ cert_validity_type: '1',
+ cert_begin_date: '',
+ cert_end_date: '',
+ mobile_no: '',
+ reg_detail: '',
+ shopro_province_id: '',
+ shopro_city_id: '',
+ shopro_district_id: '',
+ prov_id: '',
+ area_id: '',
+ district_id: '',
+ card_no: '',
+ card_name: '',
+ branch_code: '',
+ branch_name: '',
+ mp: '',
+ id_card_front_url: '',
+ id_card_back_url: '',
+ bank_card_url: '',
+ reg_name: '',
+ license_code: '',
+ license_validity_type: '1',
+ license_begin_date: '',
+ license_end_date: '',
+ legal_name: '',
+ legal_mobile: '',
+ legal_cert_no: '',
+ legal_cert_validity_type: '1',
+ legal_cert_begin_date: '',
+ legal_cert_end_date: '',
+ license_url: '',
+ legal_id_front_url: '',
+ legal_id_back_url: '',
+ account_permit_url: ''
+ };
+ }
+
+ function createFormMixin() {
+ return {
+ data: function () {
+ return {
+ isEdit: false,
+ editId: 0,
+ userId: '',
+ userLabel: '',
+ roleKey: '',
+ roleType: '',
+ roleRefId: 0,
+ roleLabel: '',
+ userOptions: [],
+ userLoading: false,
+ roleOptions: [],
+ form: defaultForm(),
+ regionPath: [],
+ areaOptions: [],
+ areaProps: { value: 'id', label: 'name', children: 'children' },
+ branchKeyword: '',
+ branchResults: [],
+ uploadUrl: Fast.api.fixurl('ajax/upload'),
+ saving: false
+ };
+ },
+ computed: {
+ bankMobile: {
+ get: function () {
+ return this.form.account_type === 'ent' ? this.form.legal_mobile : this.form.mobile_no;
+ },
+ set: function (val) {
+ if (this.form.account_type === 'ent') {
+ this.form.legal_mobile = val;
+ } else {
+ this.form.mobile_no = val;
+ }
+ this.form.mp = val;
+ }
+ }
+ },
+ mounted: function () {
+ this.loadAreaTree();
+ this.initFromConfig();
+ },
+ methods: {
+ initFromConfig: function () {
+ var init = (typeof Config !== 'undefined' && Config.onboardForm) ? Config.onboardForm : null;
+ if (!init) return;
+ this.isEdit = true;
+ this.editId = init.onboard_id || 0;
+ this.userId = init.user_id;
+ this.userLabel = init.user_label || '';
+ this.roleType = init.role_type;
+ this.roleRefId = init.role_ref_id;
+ this.roleKey = init.role_type + ':' + init.role_ref_id;
+ this.roleLabel = init.role_label || '';
+ this.form = Object.assign(defaultForm(), init.form || {});
+ this.branchKeyword = this.form.branch_name || '';
+ this.restoreRegionPath();
+ },
+ loadAreaTree: function () {
+ var vm = this;
+ var done = function (data) {
+ areaCache = data || [];
+ vm.areaOptions = areaCache;
+ vm.restoreRegionPath();
+ };
+ if (areaCache) {
+ done(areaCache);
+ return;
+ }
+ Fast.api.ajax({ url: 'shopro/area/getCascader', type: 'GET' }, function (ret, res) {
+ done(res.data || []);
+ return false;
+ });
+ },
+ restoreRegionPath: function () {
+ var ids = [];
+ if (this.form.shopro_province_id) ids.push(parseInt(this.form.shopro_province_id, 10));
+ if (this.form.shopro_city_id) ids.push(parseInt(this.form.shopro_city_id, 10));
+ if (this.form.shopro_district_id) ids.push(parseInt(this.form.shopro_district_id, 10));
+ this.regionPath = ids.filter(function (n) { return !!n; });
+ },
+ onRegionChange: function (val) {
+ val = val || [];
+ this.form.shopro_province_id = val[0] ? String(val[0]) : '';
+ this.form.shopro_city_id = val[1] ? String(val[1]) : '';
+ this.form.shopro_district_id = val[2] ? String(val[2]) : '';
+ this.form.prov_id = this.form.shopro_province_id;
+ this.form.area_id = this.form.shopro_city_id;
+ this.form.district_id = this.form.shopro_district_id;
+ },
+ searchUser: function (keyword) {
+ if (!keyword) return;
+ var vm = this;
+ vm.userLoading = true;
+ Fast.api.ajax({
+ url: 'shopro/user/user/index',
+ type: 'GET',
+ data: { offset: 0, limit: 20, searchWhere: keyword }
+ }, function (ret, res) {
+ vm.userOptions = (res.data && res.data.rows) || [];
+ vm.userLoading = false;
+ return false;
+ }, function () {
+ vm.userLoading = false;
+ });
+ },
+ onUserChange: function () {
+ var vm = this;
+ vm.roleKey = '';
+ vm.roleType = '';
+ vm.roleRefId = 0;
+ vm.roleOptions = [];
+ if (!vm.userId) return;
+ Fast.api.ajax({
+ url: 'shopro_huifu/onboard/userRoles',
+ type: 'GET',
+ data: { user_id: vm.userId }
+ }, function (ret, res) {
+ var data = res.data || {};
+ vm.roleOptions = data.roles || [];
+ if (data.user) {
+ vm.userLabel = (data.user.nickname || '') + ' (' + (data.user.mobile || data.user.id) + ')';
+ }
+ return false;
+ });
+ },
+ onRoleChange: function () {
+ var parts = String(this.roleKey || '').split(':');
+ this.roleType = parts[0] || '';
+ this.roleRefId = parseInt(parts[1] || '0', 10);
+ var role = this.roleOptions.find(function (item) {
+ return item.role_type === this.roleType && item.role_ref_id === this.roleRefId;
+ }.bind(this));
+ this.roleLabel = role ? role.role_label : '';
+ },
+ onBranchInput: function () {
+ var vm = this;
+ clearTimeout(branchTimer);
+ branchTimer = setTimeout(function () {
+ if (!vm.branchKeyword) {
+ vm.branchResults = [];
+ return;
+ }
+ Fast.api.ajax({
+ url: 'shopro_huifu/onboard/searchBranch',
+ type: 'GET',
+ data: {
+ keyword: vm.branchKeyword,
+ area_id: vm.form.area_id || vm.form.shopro_city_id
+ }
+ }, function (ret, res) {
+ vm.branchResults = res.data || [];
+ return false;
+ });
+ }, 300);
+ },
+ selectBranch: function (item) {
+ this.form.branch_code = item.branch_code;
+ this.form.branch_name = item.branch_name;
+ this.branchKeyword = item.branch_name;
+ this.branchResults = [];
+ if (item.prov_id) this.form.prov_id = item.prov_id;
+ if (item.area_id) this.form.area_id = item.area_id;
+ },
+ onUploadSuccess: function (field, res) {
+ if (res && res.code === 1 && res.data && res.data.url) {
+ this.form[field] = res.data.fullurl || res.data.url;
+ return;
+ }
+ this.$message.error((res && res.msg) || '上传失败');
+ },
+ closeForm: function () {
+ Fast.api.close();
+ },
+ submitForm: function () {
+ var vm = this;
+ if (!vm.isEdit) {
+ if (!vm.userId) {
+ Toastr.error('请选择用户');
+ return;
+ }
+ if (!vm.roleType || !vm.roleRefId) {
+ Toastr.error('请选择进件角色');
+ return;
+ }
+ }
+ vm.saving = true;
+ var url = vm.isEdit
+ ? ('shopro_huifu/onboard/edit/ids/' + vm.editId)
+ : 'shopro_huifu/onboard/add';
+ Fast.api.ajax({
+ url: url,
+ type: 'POST',
+ data: {
+ user_id: vm.userId,
+ role_type: vm.roleType,
+ role_ref_id: vm.roleRefId,
+ form: vm.form
+ }
+ }, function () {
+ vm.saving = false;
+ Fast.api.close();
+ return false;
+ }, function () {
+ vm.saving = false;
+ });
+ }
+ }
+ };
+ }
+
var Controller = {
index: function () {
withVue(function (Vue) {
@@ -49,6 +308,30 @@ define(['jquery', 'bootstrap', 'backend'], function ($, undefined, Backend) {
this.getList();
},
methods: {
+ openCreate: function () {
+ var vm = this;
+ Backend.api.open('shopro_huifu/onboard/add', '新建汇付进件', {
+ area: ['900px', '90%'],
+ callback: function () {
+ vm.getList();
+ }
+ });
+ },
+ openEdit: function (id) {
+ var vm = this;
+ Backend.api.open('shopro_huifu/onboard/edit/ids/' + id, '编辑汇付进件', {
+ area: ['900px', '90%'],
+ callback: function () {
+ vm.getList();
+ if (vm.detailVisible && vm.detailId === id) {
+ vm.openDetail(id);
+ }
+ }
+ });
+ },
+ canEditRow: function (row) {
+ return ['draft', 'failed', 'rejected'].indexOf(row.onboard_status) >= 0;
+ },
getList: function () {
var vm = this;
vm.loading = true;
@@ -131,6 +414,11 @@ define(['jquery', 'bootstrap', 'backend'], function ($, undefined, Backend) {
this.retryRow(this.detailId);
}
},
+ editFromDetail: function () {
+ if (this.detailId) {
+ this.openEdit(this.detailId);
+ }
+ },
statusText: function (status) {
var map = {
draft: '待后台审核',
@@ -144,7 +432,7 @@ define(['jquery', 'bootstrap', 'backend'], function ($, undefined, Backend) {
return map[status] || status || '-';
},
roleText: function (role) {
- return role === 'regional_agent' ? '区域代理' : (role === 'promoter' ? '推广员' : role);
+ return role === 'regional_agent' ? '区域公司' : (role === 'promoter' ? '推广员' : role);
},
formatTime: function (ts) {
if (!ts) return '-';
@@ -155,6 +443,17 @@ define(['jquery', 'bootstrap', 'backend'], function ($, undefined, Backend) {
}
});
});
+ },
+ add: function () {
+ withVue(function (Vue) {
+ new Vue({
+ el: '#huifuOnboardAdd',
+ mixins: [createFormMixin()]
+ });
+ });
+ },
+ edit: function () {
+ Controller.add();
}
};
return Controller;