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
fbbb2abe
authored
May 22, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
设置上架有效期限制
parent
76de2e20
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
166 additions
and
55 deletions
app/Http/Controllers/Api/SkuApiController.php
app/Http/Controllers/SkuController.php
app/Http/Services/LogService.php
app/Http/Services/SkuService.php
app/Http/Services/SupplierService.php
resources/views/script/SetSupplierSkuCpTimeLimitScript.blade.php
resources/views/script/SkuListScript.blade.php
resources/views/web/SetSupplierSkuCpTimeLimit.blade.php
resources/views/web/SkuList.blade.php
app/Http/Controllers/Api/SkuApiController.php
View file @
fbbb2abe
...
...
@@ -191,11 +191,17 @@ class SkuApiController extends Controller
$setType
=
$request
->
input
(
'set_type'
);
$supplierGroup
=
$request
->
input
(
'supplier_group'
);
$supplierCode
=
$request
->
input
(
'supplier_code'
);
$cpTimeDays
=
$request
->
input
(
'cp_time_days'
);
$result
=
(
new
SkuService
())
->
setSupplierSkuCpTimeLimit
(
$setType
,
$supplierGroup
,
$supplierCode
,
$cpTimeDays
);
if
(
!
$result
)
{
$this
->
response
(
-
1
,
'设置上架有效期失败'
);
$cpTimeDays
=
$request
->
input
(
'cp_time_day'
);
if
(
!
$setType
)
{
$this
->
response
(
-
1
,
'请选择设置类型'
);
}
if
(
$setType
==
1
&&
empty
(
$supplierGroup
))
{
$this
->
response
(
-
1
,
'批量设置必须选择对应的供应商性质'
);
}
if
(
$setType
==
2
&&
empty
(
$supplierCode
))
{
$this
->
response
(
-
2
,
'单个设置必须选择对应的供应商编码'
);
}
$result
=
(
new
SkuService
())
->
setSupplierSkuCpTimeLimit
(
$setType
,
$supplierGroup
,
$supplierCode
,
$cpTimeDays
);
$this
->
response
(
0
,
'设置上架有效期成功'
);
}
}
app/Http/Controllers/SkuController.php
View file @
fbbb2abe
...
...
@@ -109,10 +109,18 @@ class SkuController extends Controller
}
//设置供应商的过期时间
public
function
SetSupplierSkuCpTime
(
$request
)
public
function
SetSupplierSkuCpTime
Limit
(
$request
)
{
$model
=
new
SupplierChannelModel
();
$suppliers
=
$model
->
where
(
'is_type'
,
0
)
->
select
([
'supplier_name'
,
'supplier_code'
])
->
get
();
$supplierCodes
=
[];
foreach
(
$suppliers
as
$supplier
)
{
$supplier
=
$supplier
->
toArray
();
$supplierCodes
[
$supplier
[
'supplier_code'
]]
=
$supplier
[
'supplier_name'
]
.
'('
.
$supplier
[
'supplier_code'
]
.
')'
;
}
$this
->
data
[
'title'
]
=
'上架有效期配置'
;
$this
->
data
[
'supplierCodes'
]
=
$supplierCodes
;
return
$this
->
view
(
'上架有效期配置'
);
}
}
app/Http/Services/LogService.php
View file @
fbbb2abe
...
...
@@ -29,6 +29,29 @@ class LogService
$model
->
insert
(
$data
);
}
//批量添加日志
public
function
BatchAddLogs
(
$supplierIds
,
$type
,
$action
,
$content
,
$remark
)
{
$adminId
=
request
()
->
user
->
userId
;
$adminName
=
request
()
->
user
->
name
;
$data
=
[];
foreach
(
$supplierIds
as
$supplierId
)
{
$data
[]
=
[
'supplier_id'
=>
$supplierId
,
'type'
=>
$type
,
'action'
=>
$action
,
'content'
=>
$content
,
'remark'
=>
$remark
,
'admin_id'
=>
$adminId
,
'admin_name'
=>
$adminName
,
'add_time'
=>
time
(),
];
}
$model
=
new
LogModel
();
return
$model
->
insert
(
$data
);
}
//添加忽略审核的日志
public
function
AddIgnoreAuditCheckLog
(
$supplierId
,
$type
,
$action
,
$content
,
$remark
=
''
)
{
...
...
app/Http/Services/SkuService.php
View file @
fbbb2abe
...
...
@@ -5,6 +5,7 @@ namespace App\Http\Services;
use
App\Http\Controllers\Filter\SkuListFilter
;
use
App\Model\IntracodeModel
;
use
App\Model\LogModel
;
use
App\Model\RedisModel
;
use
App\Model\SkuUploadLogModel
;
use
App\Model\SupplierChannelModel
;
...
...
@@ -350,14 +351,31 @@ class SkuService
}
//设置上架有效期
public
function
setSupplierSkuCpTimeLimit
(
$setType
,
$supplierGroup
,
$supplierCode
,
$cpTimeDay
s
)
public
function
setSupplierSkuCpTimeLimit
(
$setType
,
$supplierGroup
,
$supplierCode
,
$cpTimeDay
)
{
$cpTimeDay
=
(
int
)
$cpTimeDay
;
$redis
=
new
RedisModel
();
//批量设置
if
(
$setType
==
1
)
{
$suppliers
=
SupplierChannelModel
::
where
(
'supplier_group'
,
$supplierCode
)
->
select
()
->
toArray
();
if
(
!
$suppliers
)
{
foreach
(
$suppliers
as
$supplier
)
{
$suppliers
=
SupplierChannelModel
::
where
(
'supplier_group'
,
$supplierGroup
)
->
select
()
->
toArray
();
$supplierIds
=
array_column
(
$suppliers
,
'supplier_ids'
);
$supplierIds
=
collect
(
$supplierIds
)
->
chunk
(
100
)
->
toArray
();
foreach
(
$supplierIds
as
$supplierIdList
)
{
//先去批量设置过期时间限制天数
SupplierChannelModel
::
whereIn
(
'supplier_id'
,
$supplierIdList
)
->
update
([
'cp_time_day'
=>
$cpTimeDay
]);
foreach
(
$supplierIdList
as
$supplierId
)
{
$originDays
=
'[ ]'
;
$ruler
=
$redis
->
hget
(
'supplier_sku_upload_ruler_v2'
,
$supplierId
);
if
(
$ruler
)
{
$ruler
=
json_decode
(
$ruler
,
true
);
$originDays
=
array_get
(
$ruler
,
'upload_validity_period'
);
$originDays
=
$originDays
?
$originDays
.
'天'
:
'[ ]'
;
}
$ruler
[
'upload_validity_period'
]
=
$cpTimeDay
;
(
new
SupplierService
())
->
saveSkuCpTimeRulerToRedis
(
$supplierId
,
$ruler
);
(
new
LogService
())
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'批量配置供应商sku上架有效期'
,
'上架有效期修由'
.
$originDays
.
'改为'
.
$cpTimeDay
.
'天'
);
}
}
}
...
...
@@ -366,7 +384,22 @@ class SkuService
if
(
$setType
==
2
)
{
$supplier
=
SupplierChannelModel
::
where
(
'supplier_code'
,
$supplierCode
)
->
first
();
if
(
!
empty
(
$supplier
))
{
$supplier
=
$supplier
->
toArray
();
$supplierId
=
$supplier
[
'supplier_id'
];
//先去批量设置过期时间限制天数
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'cp_time_day'
=>
$cpTimeDay
]);
$originDays
=
'[ ]'
;
$ruler
=
$redis
->
hget
(
'supplier_sku_upload_ruler_v2'
,
$supplierId
);
if
(
$ruler
)
{
$ruler
=
json_decode
(
$ruler
,
true
);
$originDays
=
array_get
(
$ruler
,
'upload_validity_period'
);
$originDays
=
$originDays
?
$originDays
.
'天'
:
'[ ]'
;
}
$ruler
[
'upload_validity_period'
]
=
$cpTimeDay
;
(
new
SupplierService
())
->
saveSkuCpTimeRulerToRedis
(
$supplierId
,
$ruler
);
(
new
LogService
())
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'批量配置供应商sku上架有效期'
,
'上架有效期修由'
.
$originDays
.
'改为'
.
$cpTimeDay
.
'天'
);
}
}
}
...
...
app/Http/Services/SupplierService.php
View file @
fbbb2abe
...
...
@@ -15,6 +15,7 @@ use App\Model\SupplierChannelModel;
use
App\Model\SupplierContactModel
;
use
App\Model\SupplierReceiptModel
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Redis
;
class
SupplierService
{
...
...
@@ -272,6 +273,23 @@ class SupplierService
//保存和搜索相关的标签情况
$supplierSearchTagService
=
new
SupplierSearchTagService
();
$supplierSearchTagService
->
saveSupplierSearchTags
(
$supplierId
);
//统一保存过期时间规则到redis
$redis
=
new
RedisModel
();
if
(
trim
(
$channel
[
'main_brands'
],
','
))
{
$mainBrands
=
trim
(
$channel
[
'main_brands'
],
','
);
$mainBrands
=
explode
(
','
,
$mainBrands
);
$mainBrands
=
array_map
(
function
(
$value
)
{
return
(
int
)
$value
;
},
$mainBrands
);
$supplierSkuCpTimeRuler
=
$redis
->
hget
(
'supplier_sku_upload_ruler_v2'
,
$supplierId
);
if
(
$supplierSkuCpTimeRuler
)
{
$supplierSkuCpTimeRuler
=
json_decode
(
$supplierSkuCpTimeRuler
,
true
);
$supplierSkuCpTimeRuler
[
'upload_allow_brands'
]
=
$mainBrands
;
}
else
{
$supplierSkuCpTimeRuler
=
[
'upload_allow_brands'
=>
$mainBrands
];
}
$this
->
saveSkuCpTimeRulerToRedis
(
$supplierId
,
$supplierSkuCpTimeRuler
);
}
return
$supplierId
;
...
...
@@ -364,6 +382,15 @@ class SupplierService
$redis
->
hset
(
'supplier_sku_upload_ruler'
,
$supplierId
,
$ruler
);
}
public
function
saveSkuCpTimeRulerToRedis
(
$supplierId
,
$ruler
)
{
if
(
is_array
(
$ruler
))
{
$ruler
=
json_encode
(
$ruler
);
}
$redis
=
new
RedisModel
();
$redis
->
hset
(
'supplier_sku_upload_ruler_v2'
,
$supplierId
,
$ruler
);
}
public
function
getAddress
(
$supplierId
)
{
...
...
@@ -737,11 +764,11 @@ class SupplierService
//查询供应商
public
function
querySupplier
(
$supplierName
)
{
$supplier
=
SupplierChannelModel
::
where
(
'supplier_name'
,
$supplierName
)
->
first
();
$supplier
=
!
empty
(
$supplier
)
?
$supplier
->
toArray
()
:
[];
$supplier
=
SupplierChannelModel
::
where
(
'supplier_name'
,
$supplierName
)
->
first
();
$supplier
=
!
empty
(
$supplier
)
?
$supplier
->
toArray
()
:
[];
if
(
$supplier
)
{
//查询是否是云芯商家
$existsYunxinAccount
=
SupplierAccountModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
exists
();
$existsYunxinAccount
=
SupplierAccountModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
exists
();
$supplier
[
'is_yunxin_supplier'
]
=
$existsYunxinAccount
?
1
:
0
;
}
return
$supplier
;
...
...
resources/views/script/SetSupplierSkuCpTimeLimitScript.blade.php
View file @
fbbb2abe
...
...
@@ -4,15 +4,14 @@
let
form
=
layui
.
form
;
let
table
=
layui
.
table
let
element
=
layui
.
element
;
form
.
on
(
'submit(
auditSupplier
)'
,
function
(
data
)
{
form
.
on
(
'submit(
setSupplierSkuCpTimeLimit
)'
,
function
(
data
)
{
admin
.
showLoading
({
type
:
3
});
let
supplierIds
=
getQueryVariable
(
'supplier_ids'
);
let
url
=
'/api/supplier/BatchAllocatePurchaseUser?supplier_ids='
+
supplierIds
;
let
url
=
'/api/sku/setSupplierSkuCpTimeLimit'
;
$
.
ajax
({
url
:
url
,
type
:
'
GE
T'
,
type
:
'
POS
T'
,
async
:
true
,
data
:
data
.
field
,
dataType
:
'json'
,
...
...
@@ -33,6 +32,17 @@
});
return
false
;
});
form
.
on
(
'radio(set_type)'
,
function
(
data
)
{
if
(
data
.
value
===
'1'
)
{
$
(
'#supplier_group_div'
).
show
();
$
(
'#supplier_code_div'
).
hide
();
}
else
{
$
(
'#supplier_group_div'
).
hide
();
$
(
'#supplier_code_div'
).
show
();
}
});
form
.
on
(
'submit(cancel)'
,
function
(
data
)
{
admin
.
closeThisDialog
();
});
...
...
resources/views/script/SkuListScript.blade.php
View file @
fbbb2abe
...
...
@@ -417,5 +417,16 @@
});
});
$
(
"#set_sku_cp_time_ruler"
).
click
(
function
()
{
layer
.
open
({
type
:
2
,
content
:
'/sku/SetSupplierSkuCpTimeLimit?view=iframe'
,
area
:
[
'800px'
,
'600px'
],
title
:
'上架有效期配置'
,
end
:
function
()
{
}
});
});
});
</script>
\ No newline at end of file
resources/views/web/SetSupplierSkuCpTimeLimit.blade.php
View file @
fbbb2abe
...
...
@@ -4,23 +4,38 @@
}
</style>
<div
class=
"layui-card"
>
<div
class=
"layui-card-header"
style=
"height: 170px"
>
<blockquote
class=
"layui-elem-quote layui-text"
>
<b>
渠道开发员设置
</b>
</blockquote>
<div
class=
"layui-card-header"
style=
"height: 270px"
>
<form
class=
"layui-form"
action=
""
>
<input
type=
"hidden"
name=
"supplier_ids"
value=
"{{$supplierIds}}"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
style=
"margin-left: -30px"
>
<div
class=
"layui-form-item"
style=
"margin-left: -13px"
>
@inject('singleSelectPresenter','App\Presenters\SingleSelectPresenter')
{!! $singleSelectPresenter->render('set_type','',1,[1=>'批量设置',2=>'单个设置']) !!}
</div>
<div
class=
"layui-form-item"
id=
"supplier_group_div"
>
<div
class=
"layui-inline"
style=
"margin-left: 73px"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('supplier_group','供应商性质',null,
config('fixed.SupplierGroup'),['required'=>true,'width'=>'150px']) !!}
</div>
</div>
<div
class=
"layui-form-item"
style=
"display: none"
id=
"supplier_code_div"
>
<div
class=
"layui-inline"
style=
"margin-left: 73px;"
>
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('purchase_uid','渠道开发员',null,
$userCodes,['required'=>true,'width'=>'150px']) !!}
{!! $statusPresenter->render('supplier_code','供应商编码',null,
$supplierCodes,['required'=>true,'width'=>'350px']) !!}
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
style=
"width: 150px"
><span
class=
"require"
></span>
上架有效期配置
</label>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"cp_time_day"
id=
"cp_time_day"
placeholder=
"(天数)"
class=
"layui-input"
value=
""
>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
align=
"center"
style=
"margin-top: 10px;text-align: right"
>
<button
type=
"button"
class=
"layui-btn layui-btn-sm layui-btn-info submit-loading"
lay-submit
lay-filter=
"
auditSupplier
"
>
确认
lay-filter=
"
setSupplierSkuCpTimeLimit
"
>
确认
</button>
<button
type=
"button"
class=
"layui-btn layui-btn-sm layui-btn-primary"
lay-submit
lay-filter=
"cancel"
>
取消
...
...
@@ -29,30 +44,4 @@
</div>
</form>
</div>
<div
class=
"layui-card-body"
>
<blockquote
class=
"layui-elem-quote layui-text"
>
<b>
当前选中需要批量修改渠道员的供应商列表
</b>
</blockquote>
<table
class=
"layui-table"
>
<colgroup>
<col
width=
"300"
>
<col
width=
"100"
>
<col>
</colgroup>
<thead>
<tr>
<th>
供应商名称
</th>
<th>
当前渠道开发员
</th>
</tr>
</thead>
<tbody>
@foreach($suppliers as $supplier)
<tr>
<td>
{{$supplier['supplier_name']}}
</td>
<td>
{{$supplier['purchase_username']}}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
resources/views/web/SkuList.blade.php
View file @
fbbb2abe
...
...
@@ -15,6 +15,9 @@
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
cancel_set_prefer
">取消精选</button>
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
sync_erp_rate
">同步ERP汇率</button>
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
set_sku_tag
">设置标签</button>
@if (checkPerm('SetSupplierSkuCpTimeLimit'))
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
set_sku_cp_time_ruler
">上架有效期配置</button>
@endif
@endif
</div>
...
...
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