Commit 5a8ae8cd by 杨树贤

Merge branch 'master' into ysx-CRM转化供应商流程-20260518

parents e6b9fb38 e1030a14
......@@ -10,3 +10,4 @@ Homestead.json
/vendor/_laravel_ide
/storage/framework/views
/storage
CLAUDE.md
\ No newline at end of file
......@@ -87,6 +87,20 @@ class SupplierFilter
$query->where('sign_com_id', $map['sign_com_id']);
}
if (!empty($map['agency_brands'])) {
$agencyBrands = array_filter(explode(',', $map['agency_brands']), function ($value) {
return trim($value) !== '';
});
if (!empty($agencyBrands)) {
$query->where(function ($q) use ($agencyBrands) {
foreach ($agencyBrands as $brandId) {
$brandId = trim($brandId);
$q->orWhereRaw("CONCAT(',', REPLACE(agency_brands, ' ', ''), ',') LIKE '%,{$brandId},%'");
}
});
}
}
if (!empty($map['supplier_source'])) {
$query->where('supplier_source', $map['supplier_source']);
}
......@@ -291,24 +305,15 @@ class SupplierFilter
$canViewFakeSupplier = checkPerm('ViewFakeSupplier');
$canViewBlockSupplier = checkPerm('ViewBlockSupplier');
$canViewDisableSupplier = checkPerm('ViewDisableSupplier');
$canViewConfirmSupplier = checkPerm('ViewConfirmSupplier');
// 构建复合查询条件:基础条件 OR 特殊状态
$query->where(function ($mainQuery) use ($canViewFakeSupplier, $canViewBlockSupplier, $canViewDisableSupplier, $canViewConfirmSupplier, $userId, $codeId, $canViewAllSupplier, $canViewSubordinateSupplier) {
$query->where(function ($mainQuery) use ($canViewFakeSupplier, $canViewBlockSupplier, $canViewDisableSupplier, $userId, $codeId, $canViewAllSupplier, $canViewSubordinateSupplier) {
// 主要条件组:基础业务条件
$mainQuery->where(function ($baseQuery) use ($canViewFakeSupplier, $canViewConfirmSupplier, $userId, $codeId, $canViewAllSupplier, $canViewSubordinateSupplier) {
$mainQuery->where(function ($baseQuery) use ($canViewFakeSupplier, $userId, $codeId, $canViewAllSupplier, $canViewSubordinateSupplier) {
// 基础类型限制
if (!$canViewFakeSupplier) {
$baseQuery->where('is_type', 0);
}
// 如果没有查看待确认供应商权限,过滤掉待确认和CRM转移供应商不通过状态的供应商
if (!$canViewConfirmSupplier) {
$baseQuery->whereNotIn('status', [
SupplierChannelModel::STATUS_CONFIRM,
SupplierChannelModel::STATUS_CRM_REJECTED
]);
}
// 权限相关的条件
if (!$canViewAllSupplier) {
if ($canViewSubordinateSupplier) {
......@@ -347,10 +352,6 @@ class SupplierFilter
if ($canViewDisableSupplier && !checkPerm('ViewAllSupplier')) {
$mainQuery->orWhere('status', SupplierChannelModel::STATUS_DISABLE);
}
if ($canViewConfirmSupplier && !checkPerm('ViewAllSupplier')) {
$mainQuery->orWhere('status', SupplierChannelModel::STATUS_CONFIRM);
$mainQuery->orWhere('status', SupplierChannelModel::STATUS_CRM_REJECTED);
}
// //只有原厂、代理商需要走权限,其他性质的随便看
// if (!checkPerm('ViewAllSupplier')) {
......
......@@ -86,25 +86,24 @@ class SupplierApplyService
'audit_uid' => request()->user->userId,
]);
$apply = SupplierApplyModel::where('id', $applyId)->first()->toArray();
$isNewAccount = false; // 标记是否为新创建的账号
if ($result ) {
if ($status == SupplierApplyModel::STATUS_PASS) {
$existAccount = SupplierAccountModel::where('supplier_code', $apply['supplier_code'])->exists();
//如果没有芯链账号,那么就要新增芯链账号
$existAccount = SupplierAccountModel::where('supplier_code', $apply['supplier_code'])->first();
if ($existAccount) {
SupplierAccountModel::where('supplier_code', $apply['supplier_code'])->update([
// 账号已存在,只更新联系信息,不修改密码(避免覆盖用户已修改的密码)
$existAccount->update([
'mobile' => $apply['mobile'],
'email' => $apply['email'],
'contacts_name' => $apply['contact_name'],
'password_raw' => 123456,
'password' => Hash::make(123456),
'create_time' => time(),
'update_time' => time(),
'a_type' => 1,
'a_status' => 1,
'create_uid' => 1000,
'source' => 2,
]);
}else{
//如果是通过并且已经存在,那么就要替换掉对应供应商的账号和密码
} else {
// 如果没有芯链账号,则新增芯链账号
$isNewAccount = true;
SupplierAccountModel::insert([
'supplier_id' => $apply['supplier_id'],
'supplier_code' => $apply['supplier_code'],
......@@ -112,17 +111,21 @@ class SupplierApplyService
'update_time' => time(),
'email' => $apply['email'],
'contacts_name' => $apply['contact_name'],
'password_raw' => 123456,
'password' => Hash::make(123456),
'password_raw' => '123456',
'password' => Hash::make('123456'),
'source' => 2,
]);
}
}
//无论是否通过,都要发短信通知
if ($status == SupplierApplyModel::STATUS_REJECT) {
$message = "${apply['contact_name']} 先生/女生您好,您的“芯链入驻申请”已收到,审核结果为:不通过,原因为:${auditReason},如对审核结果有疑问,可联系您在猎芯的专属渠道经理(周强),联系电话:13427991931,联系邮箱:vendor@ichunt.com";
$message = "{$apply['contact_name']} 先生/女生您好,您的芯链入驻申请已收到,审核结果为:不通过,原因为:{$auditReason},如对审核结果有疑问,可联系您在猎芯的专属渠道经理(周强),联系电话:13427991931,联系邮箱:vendor@ichunt.com";
} else {
$message = "${apply['contact_name']} 先生/女生您好,您的“芯链入驻申请”已收到,审核结果为:通过,芯链登录网址:http://xinlian.ichunt.com,您的芯链手机号:${apply['mobile']},初始密码:123456,请在登录芯链后修改密码,后续有任何疑问都可联系您在猎芯的专属渠道经理(周强),联系电话:13427991931,联系邮箱:vendor@ichunt.com;";
if ($isNewAccount) {
$message = "{$apply['contact_name']} 先生/女生您好,您的芯链入驻申请已收到,审核结果为:通过,芯链登录网址:http://xinlian.ichunt.com,您的芯链手机号:{$apply['mobile']},初始密码:123456,请在登录芯链后修改密码,后续有任何疑问都可联系您在猎芯的专属渠道经理(周强),联系电话:13427991931,联系邮箱:vendor@ichunt.com";
} else {
$message = "{$apply['contact_name']} 先生/女生您好,您的芯链入驻申请已收到,审核结果为:通过,芯链登录网址:http://xinlian.ichunt.com,您的芯链手机号:{$apply['mobile']},请使用原密码登录,如忘记密码请联系猎芯渠道经理,后续有任何疑问都可联系您在猎芯的专属渠道经理(周强),联系电话:13427991931,联系邮箱:vendor@ichunt.com";
}
}
$data = [];
$data['data']['title'] = $message;
......
......@@ -130,6 +130,59 @@
}
})
var agencyBrandsSelector = xmSelect.render({
el: '#agency_brands_filter',
filterable: true,
paging: true,
height: '250px',
size: 'mini',
direction: 'auto',
autoRow: true,
prop: {
name: 'brand_name',
value: 'brand_id',
},
remoteSearch: true,
pageRemote: true,
template({item, sels, name, value}) {
return item.brand_name + '<span style="position: absolute; right: 10px; color: #8799a3">' +
item.mapping_brand_names + '</span>'
},
filterMethod: function(val, item, index, prop) {},
pageSize: 30,
remoteMethod: function(val, cb, show, pageIndex) {
$.ajax({
url: '/api/common/getStandardBrandList',
type: 'post',
data: {
brand_name: val,
page: pageIndex
},
dataType: 'json',
timeout: 10000,
success: function(res) {
if (!res) return layer.msg('网络错误,请重试', {icon: 5});
if (res.err_code === 0) {
cb(res.data, res.last_page);
} else {
layer.msg(res.err_msg, {icon: 6});
}
},
error: function() {
return layer.msg('网络错误,请重试', {icon: 5});
}
});
},
on: function(data) {
let arr = data.arr;
let brandIds = '';
for (let i in arr) {
brandIds += arr[i].brand_id + ',';
}
$('#agency_brands_filter_value').val(brandIds);
},
})
let cols = [
{type: 'checkbox', fixed: true},
{
......
......@@ -167,7 +167,7 @@
{!! $multiTransformableSelectPresenter->render(['has_uploaded_sku'=>'历史SKU合作'],
['has_uploaded_sku'=>[1=>'是',-1=>'否']]) !!}
</div>
<button class="layui-btn layui-btn-sm" type="button" id="show_filter_row2">展开</button>
<button class="layui-btn layui-btn-sm" type="button" id="show_filter_row2" style="margin-left: 10px">展开</button>
</div>
</div>
<div class="layui-row" id="filter_row2" style="display: none">
......@@ -226,7 +226,7 @@
</div>
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('has_order_contract','通过芯链上传合同','',[1=>'是',-1=>'否']) !!}
{!! $statusPresenter->render('has_order_contract','芯链上传合同','',[1=>'是',-1=>'否']) !!}
</div>
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
......@@ -244,16 +244,24 @@
@inject('multiSelectorPresenter','App\Presenters\MultiSelectorPresenter')
{!! $multiSelectorPresenter->render('region','区域','',$regionData) !!}
</div>
<div class="layui-inline">
<label class="layui-form-label">创建部门</label>
<div class="layui-input-inline">
<div id="create_user_department" style="width: 150px"></div>
</div>
</div>
<div class="layui-inline">
<div class="layui-inline" style="margin-left: 10px">
@inject('multiTransformableSelectPresenter','App\Presenters\Filter\MultiTransformableSelectPresenter')
{!! $multiTransformableSelectPresenter->render(['data_channel_uid' => '数据跟单员'],['data_channel_uid' => $userCodes]) !!}
</div>
<div class="layui-inline">
<label class="layui-form-label">代理品牌</label>
<div class="layui-input-inline">
<div id="agency_brands_filter" style="width: 425px"></div>
<input type="hidden" name="agency_brands" id="agency_brands_filter_value" value="">
</div>
</div>
<div class="layui-row">
<div class="layui-inline" style="width: 600px">
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
......
......@@ -178,7 +178,7 @@
['has_uploaded_sku'=>[1=>'是',-1=>'否']]); ?>
</div>
<button class="layui-btn layui-btn-sm" type="button" id="show_filter_row2">展开</button>
<button class="layui-btn layui-btn-sm" type="button" id="show_filter_row2" style="margin-left: 10px">展开</button>
</div>
</div>
<div class="layui-row" id="filter_row2" style="display: none">
......@@ -249,7 +249,7 @@
</div>
<div class="layui-inline">
<?php $statusPresenter = app('App\Presenters\StatusPresenter'); ?>
<?php echo $statusPresenter->render('has_order_contract','通过芯链上传合同','',[1=>'是',-1=>'否']); ?>
<?php echo $statusPresenter->render('has_order_contract','芯链上传合同','',[1=>'是',-1=>'否']); ?>
</div>
<div class="layui-inline">
......@@ -272,17 +272,25 @@
<?php echo $multiSelectorPresenter->render('region','区域','',$regionData); ?>
</div>
<div class="layui-inline">
<label class="layui-form-label">创建部门</label>
<div class="layui-input-inline">
<div id="create_user_department" style="width: 150px"></div>
</div>
</div>
<div class="layui-inline">
<div class="layui-inline" style="margin-left: 10px">
<?php $multiTransformableSelectPresenter = app('App\Presenters\Filter\MultiTransformableSelectPresenter'); ?>
<?php echo $multiTransformableSelectPresenter->render(['data_channel_uid' => '数据跟单员'],['data_channel_uid' => $userCodes]); ?>
</div>
<div class="layui-inline">
<label class="layui-form-label">代理品牌</label>
<div class="layui-input-inline">
<div id="agency_brands_filter" style="width: 425px"></div>
<input type="hidden" name="agency_brands" id="agency_brands_filter_value" value="">
</div>
</div>
<div class="layui-row">
<div class="layui-inline" style="width: 600px">
<?php $transformableTimeIntervalPresenter = app('App\Presenters\Filter\TransformableTimeIntervalPresenter'); ?>
......
......@@ -130,6 +130,59 @@
}
})
var agencyBrandsSelector = xmSelect.render({
el: '#agency_brands_filter',
filterable: true,
paging: true,
height: '250px',
size: 'mini',
direction: 'auto',
autoRow: true,
prop: {
name: 'brand_name',
value: 'brand_id',
},
remoteSearch: true,
pageRemote: true,
template({item, sels, name, value}) {
return item.brand_name + '<span style="position: absolute; right: 10px; color: #8799a3">' +
item.mapping_brand_names + '</span>'
},
filterMethod: function(val, item, index, prop) {},
pageSize: 30,
remoteMethod: function(val, cb, show, pageIndex) {
$.ajax({
url: '/api/common/getStandardBrandList',
type: 'post',
data: {
brand_name: val,
page: pageIndex
},
dataType: 'json',
timeout: 10000,
success: function(res) {
if (!res) return layer.msg('网络错误,请重试', {icon: 5});
if (res.err_code === 0) {
cb(res.data, res.last_page);
} else {
layer.msg(res.err_msg, {icon: 6});
}
},
error: function() {
return layer.msg('网络错误,请重试', {icon: 5});
}
});
},
on: function(data) {
let arr = data.arr;
let brandIds = '';
for (let i in arr) {
brandIds += arr[i].brand_id + ',';
}
$('#agency_brands_filter_value').val(brandIds);
},
})
let cols = [
{type: 'checkbox', fixed: true},
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment