Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c45dd732
authored
Jun 16, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加供应商同时要添加联系人
parent
359d2412
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
151 additions
and
40 deletions
app/Http/Controllers/Api/SupplierApiController.php
app/Http/Controllers/SupplierController.php
app/Http/Services/SupplierContactService.php
app/Http/Services/SupplierService.php
app/Http/Validators/SupplierValidator.php
resources/views/script/supplier/SupplierBaseScript.blade.php
resources/views/web/supplier/SupplierBase.blade.php
app/Http/Controllers/Api/SupplierApiController.php
View file @
c45dd732
...
@@ -43,6 +43,10 @@ class SupplierApiController extends Controller
...
@@ -43,6 +43,10 @@ class SupplierApiController extends Controller
'pay_type'
,
'pay_type'
,
'trading_method'
,
'trading_method'
,
//省市
'province_id'
,
'city_id'
,
//收发货地址
//收发货地址
'return_phone'
,
'return_phone'
,
'return_address'
,
'return_address'
,
...
@@ -82,9 +86,21 @@ class SupplierApiController extends Controller
...
@@ -82,9 +86,21 @@ class SupplierApiController extends Controller
if
(
$validateResult
)
{
if
(
$validateResult
)
{
$this
->
response
(
-
1
,
$validateResult
);
$this
->
response
(
-
1
,
$validateResult
);
}
}
$channel
=
$request
->
only
(
$this
->
channelMap
);
$channelMap
=
$this
->
channelMap
;
$channelMap
=
array_merge
(
$channelMap
,
[
'supplier_consignee'
,
'supplier_position'
,
'supplier_email'
,
'supplier_mobile'
,
'supplier_telephone'
,
'supplier_qq'
,
'supplier_fax'
,
'can_check_uids'
]);
$channel
=
$request
->
only
(
$channelMap
);
$service
=
new
SupplierService
();
$service
=
new
SupplierService
();
$result
=
$service
->
saveSupplier
(
$channel
);
$result
=
$service
->
saveSupplier
(
$channel
);
dd
(
$result
);
if
(
!
$result
)
{
if
(
!
$result
)
{
$this
->
response
(
-
1
,
'操作失败'
);
$this
->
response
(
-
1
,
'操作失败'
);
}
}
...
@@ -346,7 +362,7 @@ class SupplierApiController extends Controller
...
@@ -346,7 +362,7 @@ class SupplierApiController extends Controller
$adminService
=
new
AdminUserService
();
$adminService
=
new
AdminUserService
();
$user
=
$adminService
->
getAdminUserInfoByCodeId
(
$channelUid
);
$user
=
$adminService
->
getAdminUserInfoByCodeId
(
$channelUid
);
$logService
=
new
LogService
();
$logService
=
new
LogService
();
$logService
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'设置云芯采购员'
,
'设置云芯采购员为 : '
.
$user
[
'name'
]);
$logService
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'设置云芯采购员'
,
'设置云芯采购员为 : '
.
$user
[
'name'
]);
$this
->
response
(
0
,
'设置云芯采购成功'
);
$this
->
response
(
0
,
'设置云芯采购成功'
);
}
else
{
}
else
{
$this
->
response
(
-
1
,
'设置云芯采购失败'
);
$this
->
response
(
-
1
,
'设置云芯采购失败'
);
...
...
app/Http/Controllers/SupplierController.php
View file @
c45dd732
...
@@ -145,6 +145,9 @@ class SupplierController extends Controller
...
@@ -145,6 +145,9 @@ class SupplierController extends Controller
'value'
=>
$userId
,
'value'
=>
$userId
,
];
];
}
}
//省市区数据放到script模板
$regionService
=
new
RegionService
();
$this
->
data
[
'region_data'
]
=
$regionService
->
getCityRegionData
();
//编辑
//编辑
$this
->
data
[
'title'
]
=
'编辑供应商'
;
$this
->
data
[
'title'
]
=
'编辑供应商'
;
$supplierId
=
$request
->
get
(
'supplier_id'
);
$supplierId
=
$request
->
get
(
'supplier_id'
);
...
...
app/Http/Services/SupplierContactService.php
View file @
c45dd732
...
@@ -71,10 +71,7 @@ class SupplierContactService
...
@@ -71,10 +71,7 @@ class SupplierContactService
}
else
{
}
else
{
$canCheckUids
=
''
;
$canCheckUids
=
''
;
}
}
//不存在则写入
// if (!in_array($contact['can_check_uids'], $channelUid)) {
// $channelUid[] = $contact['can_check_uids'];
// }
$supplierModel
->
where
(
'supplier_id'
,
$supplierId
)
->
update
([
$supplierModel
->
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'channel_uid'
=>
$canCheckUids
,
'channel_uid'
=>
$canCheckUids
,
'update_time'
=>
time
(),
'update_time'
=>
time
(),
...
...
app/Http/Services/SupplierService.php
View file @
c45dd732
...
@@ -107,6 +107,8 @@ class SupplierService
...
@@ -107,6 +107,8 @@ class SupplierService
$channel
[
'return_consignee'
],
$channel
[
'shipping_address'
],
$channel
[
'cn_delivery_time_period'
],
$channel
[
'us_delivery_time_period'
]);
$channel
[
'return_consignee'
],
$channel
[
'shipping_address'
],
$channel
[
'cn_delivery_time_period'
],
$channel
[
'us_delivery_time_period'
]);
$skuAuditRulerService
=
new
SupplierSkuAuditRulerService
();
$skuAuditRulerService
=
new
SupplierSkuAuditRulerService
();
$channel
[
'sku_audit_ruler'
]
=
$skuAuditRulerService
->
getSkuAuditRulerForDB
(
$channel
[
'sku_audit_ruler'
]);
$channel
[
'sku_audit_ruler'
]
=
$skuAuditRulerService
->
getSkuAuditRulerForDB
(
$channel
[
'sku_audit_ruler'
]);
//新增供应商操作
if
(
empty
(
$channel
[
'supplier_id'
]))
{
if
(
empty
(
$channel
[
'supplier_id'
]))
{
//先去插入到channel表
//先去插入到channel表
$channel
[
'create_uid'
]
=
request
()
->
user
->
userId
;
$channel
[
'create_uid'
]
=
request
()
->
user
->
userId
;
...
@@ -120,8 +122,29 @@ class SupplierService
...
@@ -120,8 +122,29 @@ class SupplierService
return
$value
;
return
$value
;
},
$channel
);
},
$channel
);
$channel
[
'status'
]
=
SupplierChannelModel
::
STATUS_PENDING
;
$channel
[
'status'
]
=
SupplierChannelModel
::
STATUS_PENDING
;
$channel
[
'region'
]
=
2
;
$contactField
=
[
'supplier_consignee'
,
'supplier_position'
,
'supplier_email'
,
'supplier_mobile'
,
'supplier_telephone'
,
'supplier_qq'
,
'supplier_fax'
,
'can_check_uids'
,
];
$contact
=
array_only
(
$channel
,
$contactField
);
$channel
=
array_except
(
$channel
,
$contactField
);
$channel
[
'channel_uid'
]
=
$contact
[
'can_check_uids'
];
$supplierId
=
$this
->
newSupplierId
=
$model
->
insertGetId
(
$channel
);
$supplierId
=
$this
->
newSupplierId
=
$model
->
insertGetId
(
$channel
);
$this
->
saveSupplierCode
(
$supplierId
);
$this
->
saveSupplierCode
(
$supplierId
);
//同时添加联系人
$contact
[
'supplier_id'
]
=
$supplierId
;
$contact
[
'add_time'
]
=
time
();
$contact
[
'admin_id'
]
=
request
()
->
user
->
userId
;
$contactModel
=
new
SupplierContactModel
();
$contactModel
->
insert
(
$contact
);
}
else
{
}
else
{
$supplierId
=
$this
->
newSupplierId
=
$channel
[
'supplier_id'
];
$supplierId
=
$this
->
newSupplierId
=
$channel
[
'supplier_id'
];
$channel
[
'status'
]
=
SupplierChannelModel
::
STATUS_IN_REVIEW
;
$channel
[
'status'
]
=
SupplierChannelModel
::
STATUS_IN_REVIEW
;
...
@@ -193,21 +216,6 @@ class SupplierService
...
@@ -193,21 +216,6 @@ class SupplierService
return
$data
;
return
$data
;
}
}
public
function
getSkuRulerData
(
$skuUploadRuler
)
{
$defaultRuler
=
config
(
'fixed.SkuUploadRuler'
);
$rule
=
[];
foreach
(
$defaultRuler
as
$ruleName
=>
$value
)
{
if
(
isset
(
$skuUploadRuler
[
$ruleName
]))
{
$rule
[
$ruleName
]
=
1
;
}
else
{
$rule
[
$ruleName
]
=
0
;
}
}
$rule
=
json_encode
(
$rule
);
return
$rule
;
}
//报错供应商编码,包括系统生成的和自定义规则生成的
//报错供应商编码,包括系统生成的和自定义规则生成的
private
function
saveSupplierCode
(
$supplierId
)
private
function
saveSupplierCode
(
$supplierId
)
{
{
...
...
app/Http/Validators/SupplierValidator.php
View file @
c45dd732
...
@@ -19,7 +19,6 @@ class SupplierValidator
...
@@ -19,7 +19,6 @@ class SupplierValidator
$rules
=
[
$rules
=
[
'supplier_name'
=>
'required'
,
'supplier_name'
=>
'required'
,
'legal_representative'
=>
'required'
,
'legal_representative'
=>
'required'
,
// 'register_company_name' => 'required',
'stockup_type'
=>
'required'
,
'stockup_type'
=>
'required'
,
'supplier_address'
=>
'required'
,
'supplier_address'
=>
'required'
,
'region'
=>
'required'
,
'region'
=>
'required'
,
...
@@ -32,12 +31,19 @@ class SupplierValidator
...
@@ -32,12 +31,19 @@ class SupplierValidator
'upload_file.business_license'
=>
'required'
,
'upload_file.business_license'
=>
'required'
,
'cn_ratio'
=>
'min:1'
,
'cn_ratio'
=>
'min:1'
,
'us_ratio'
=>
'min:1'
,
'us_ratio'
=>
'min:1'
,
'contact.supplier_consignee.*'
=>
'required|max:50'
,
'contact.supplier_mobile.*'
=>
'required|max:30'
,
'contact.supplier_telephone.*'
=>
'max:30'
,
'contact.supplier_email.*'
=>
'required|email'
,
'contact.supplier_position.*'
=>
'required|max:30'
,
];
];
$contactRuler
=
[
'supplier_consignee'
=>
'required|max:50'
,
'supplier_mobile'
=>
'required|max:30'
,
'supplier_telephone'
=>
'required|max:30'
,
'supplier_email'
=>
'required|email'
,
'supplier_position'
=>
'required|max:30'
,
'can_check_uids'
=>
'required'
,
];
//第一次新增的时候,是要校验联系人的
if
(
empty
(
$requestData
[
'supplier_id'
]))
{
$rules
=
array_merge
(
$rules
,
$contactRuler
);
}
//币种为人民币的话需要验证税号
//币种为人民币的话需要验证税号
if
(
$requestData
[
'currency'
]
==
1
)
{
if
(
$requestData
[
'currency'
]
==
1
)
{
...
@@ -49,7 +55,6 @@ class SupplierValidator
...
@@ -49,7 +55,6 @@ class SupplierValidator
$rules
[
'purchase_uid'
]
=
'required'
;
$rules
[
'purchase_uid'
]
=
'required'
;
}
}
//营业执照是不能为空的
//营业执照是不能为空的
$messages
=
$this
->
messages
();
$messages
=
$this
->
messages
();
$validator
=
Validator
::
make
(
$requestData
,
$rules
,
$messages
);
$validator
=
Validator
::
make
(
$requestData
,
$rules
,
$messages
);
if
(
$validator
->
fails
())
{
if
(
$validator
->
fails
())
{
...
@@ -98,14 +103,16 @@ class SupplierValidator
...
@@ -98,14 +103,16 @@ class SupplierValidator
'us_delivery_time.regex'
=>
'香港货期格式不正确'
,
'us_delivery_time.regex'
=>
'香港货期格式不正确'
,
'cn_delivery_time.regex'
=>
'大陆货期格式不正确'
,
'cn_delivery_time.regex'
=>
'大陆货期格式不正确'
,
'tax_number.required'
=>
'如果选择币种为人民币,则公司税号不能为空'
,
'tax_number.required'
=>
'如果选择币种为人民币,则公司税号不能为空'
,
'contact.supplier_consignee.*.required'
=>
'联系方式的联系人不能为空'
,
'supplier_consignee.required'
=>
'联系方式的联系人不能为空'
,
'contact.supplier_consignee.*.max'
=>
'联系方式的联系人不能超过50个字符'
,
'supplier_consignee.max'
=>
'联系方式的联系人不能超过50个字符'
,
'contact.supplier_position.*.required'
=>
'联系方式的职称不能为空'
,
'supplier_position.required'
=>
'联系方式的职称不能为空'
,
'contact.supplier_position.*.max'
=>
'联系方式的职称不能超过30个字符'
,
'supplier_position.max'
=>
'联系方式的职称不能超过30个字符'
,
'contact.supplier_mobile.*.required'
=>
'联系方式的手机号不能为空'
,
'supplier_telephone.required'
=>
'联系方式的座机号不能为空'
,
'contact.supplier_mobile.*.max'
=>
'联系方式的手机号不能超过30个字符'
,
'supplier_mobile.required'
=>
'联系方式的手机号不能为空'
,
'contact.supplier_email.*.required'
=>
'联系方式的邮箱不能为空'
,
'supplier_mobile.max'
=>
'联系方式的手机号不能超过30个字符'
,
'contact.supplier_email.*.email'
=>
'联系方式的邮箱格式不对'
,
'supplier_email.required'
=>
'联系方式的邮箱不能为空'
,
'supplier_email.email'
=>
'联系方式的邮箱格式不对'
,
'can_check_uids.required'
=>
'联系方式对应的采购员不能为空'
,
'shipping_address.max'
=>
'发货地址不能超过100个字符'
,
'shipping_address.max'
=>
'发货地址不能超过100个字符'
,
'return_address.max'
=>
'退货地址不能超过100个字符'
,
'return_address.max'
=>
'退货地址不能超过100个字符'
,
'return_consignee.max'
=>
'退货收货人不能超过50个字符'
,
'return_consignee.max'
=>
'退货收货人不能超过50个字符'
,
...
...
resources/views/script/supplier/SupplierBaseScript.blade.php
View file @
c45dd732
...
@@ -48,6 +48,15 @@
...
@@ -48,6 +48,15 @@
}
}
});
});
//监听所在区域变化,中国才显示省市选择
form
.
on
(
'select(region)'
,
function
(
data
)
{
if
(
data
.
value
===
'2'
)
{
$
(
'.city-selector'
).
show
();
}
else
{
$
(
'.city-selector'
).
hide
();
}
});
//渲染主营品牌的多选
//渲染主营品牌的多选
function
getBrandOption
(
element
,
brandType
)
{
function
getBrandOption
(
element
,
brandType
)
{
let
brandUrl
=
'/api/common/getBrandList?type='
+
brandType
;
let
brandUrl
=
'/api/common/getBrandList?type='
+
brandType
;
...
...
resources/views/web/supplier/SupplierBase.blade.php
View file @
c45dd732
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
</div>
</div>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
<span
class=
"require"
>
*
</span>
注册公司名 :
</label>
<label
class=
"layui-form-label"
>
注册公司名 :
</label>
<div
class=
"layui-input-block"
>
<div
class=
"layui-input-block"
>
<input
type=
"text"
name=
"register_company_name"
id=
"register_company_name"
<input
type=
"text"
name=
"register_company_name"
id=
"register_company_name"
placeholder=
"请输入注册公司名"
class=
"layui-input"
placeholder=
"请输入注册公司名"
class=
"layui-input"
...
@@ -53,11 +53,11 @@
...
@@ -53,11 +53,11 @@
</div>
</div>
<div
class=
"layui-col-md8"
>
<div
class=
"layui-col-md8"
>
<div>
<div>
<div
class=
"city-selector"
></div>
<div
class=
"city-selector"
style=
"display: none"
></div>
</div>
</div>
</div>
</div>
<div
class=
"layui-col-md12"
>
<div
class=
"layui-col-md12"
>
<label
class=
"layui-form-label"
>
注册地址 :
<label
class=
"layui-form-label"
>
<span
class=
"require"
>
*
</span>
注册地址 :
</label>
</label>
<div
class=
"layui-input-block"
>
<div
class=
"layui-input-block"
>
<input
type=
"text"
name=
"supplier_address"
id=
"supplier_address"
<input
type=
"text"
name=
"supplier_address"
id=
"supplier_address"
...
@@ -165,7 +165,78 @@
...
@@ -165,7 +165,78 @@
<b>
联系人
</b>
<b>
联系人
</b>
</blockquote>
</blockquote>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-col-md5"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
联系人
</label>
<div
class=
"layui-input-block block-42"
>
<input
type=
"text"
name=
"supplier_consignee"
id=
"supplier_consignee"
placeholder=
"请输入联系人"
class=
"layui-input"
value=
""
>
</div>
</div>
<div
class=
"layui-col-md5"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
职位
</label>
<div
class=
"layui-input-block block-42"
>
<input
type=
"text"
name=
"supplier_position"
id=
"supplier_position"
placeholder=
"请输入职位"
class=
"layui-input"
value=
""
>
</div>
</div>
<div
class=
"layui-col-md2"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-col-md5"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
邮箱
</label>
<div
class=
"layui-input-block block-42"
>
<input
type=
"text"
name=
"supplier_email"
id=
"supplier_email"
placeholder=
"请输入邮箱"
class=
"layui-input"
value=
""
>
</div>
</div>
<div
class=
"layui-col-md5"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
手机号
</label>
<div
class=
"layui-input-block block-42"
>
<input
type=
"text"
name=
"supplier_mobile"
id=
"supplier_mobile"
placeholder=
"请输入手机号"
class=
"layui-input"
value=
""
>
</div>
</div>
<div
class=
"layui-col-md2"
></div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-col-md5"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
座机
</label>
<div
class=
"layui-input-block block-42"
>
<input
type=
"text"
name=
"supplier_telephone"
id=
"supplier_telephone"
placeholder=
"请输入座机"
class=
"layui-input"
value=
""
>
</div>
</div>
<div
class=
"layui-col-md5"
>
<label
class=
"layui-form-label"
>
QQ
</label>
<div
class=
"layui-input-block block-42"
>
<input
type=
"text"
name=
"supplier_qq"
id=
"supplier_qq"
placeholder=
"请输入QQ"
class=
"layui-input"
value=
""
>
</div>
</div>
<div
class=
"layui-col-md2"
></div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-col-md5"
>
<label
class=
"layui-form-label"
>
传真
</label>
<div
class=
"layui-input-block block-42"
>
<input
type=
"text"
name=
"supplier_fax"
id=
"supplier_fax"
placeholder=
"请输入传真"
class=
"layui-input"
value=
""
>
</div>
</div>
<div
class=
"layui-col-md5"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('can_check_uids','采购员','',
$userCodes,['required'=>true]) !!}
</div>
<div
class=
"layui-col-md2"
></div>
</div>
</div>
@endif
@endif
@include('script.supplier.SupplierBaseScript')
@include('script.supplier.SupplierBaseScript')
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment