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
221d6b83
authored
Jul 25, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
有效期设置
parent
4608a423
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
113 additions
and
34 deletions
app/Http/Controllers/Api/SkuApiController.php
app/Http/Controllers/SkuController.php
app/Http/Services/SkuService.php
app/Http/Services/SupplierService.php
app/Http/Validators/SupplierValidator.php
app/Http/routes.php
app/Model/SupplierChannelModel.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
vendor/_laravel_idea/_ide_helper_facades.php
app/Http/Controllers/Api/SkuApiController.php
View file @
221d6b83
...
...
@@ -191,18 +191,28 @@ class SkuApiController extends Controller
$setType
=
$request
->
input
(
'set_type'
);
$supplierGroup
=
$request
->
input
(
'supplier_group'
);
$supplierCode
=
$request
->
input
(
'supplier_code'
);
$cpTimeDays
=
$request
->
input
(
'cp_time_day'
);
$dayType
=
$request
->
input
(
'day_type'
);
$cpTimeData
=
[
'day_type'
=>
$request
->
input
(
'day_type'
),
'cp_time_day'
=>
$request
->
input
(
'cp_time_day'
),
'futures_day_type'
=>
$request
->
input
(
'futures_day_type'
),
'futures_cp_time_day'
=>
$request
->
input
(
'futures_cp_time_day'
),
];
if
(
empty
(
$cpTimeData
[
'cp_time_day'
])
&&
$cpTimeData
[
'day_type'
]
==
1
)
{
$this
->
response
(
-
1
,
'货期有效期天数不能为0'
);
}
if
(
empty
(
$cpTimeData
[
'futures_cp_time_day'
])
&&
$cpTimeData
[
'futures_day_type'
]
==
1
)
{
$this
->
response
(
-
1
,
'现货有效期天数不能为0'
);
}
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
,
$dayType
,
$cpTimeDays
);
(
new
SkuService
())
->
setSupplierSkuCpTimeLimit
(
$setType
,
$supplierGroup
,
$supplierCode
,
$cpTimeData
);
$this
->
response
(
0
,
'设置上架有效期成功'
);
}
}
app/Http/Controllers/SkuController.php
View file @
221d6b83
...
...
@@ -119,8 +119,8 @@ class SkuController extends Controller
$supplier
=
$supplier
->
toArray
();
$supplierCodes
[
$supplier
[
'supplier_code'
]]
=
$supplier
[
'supplier_name'
]
.
'('
.
$supplier
[
'supplier_code'
]
.
')'
;
}
$this
->
data
[
'title'
]
=
'
上架
有效期配置'
;
$this
->
data
[
'title'
]
=
'
商品
有效期配置'
;
$this
->
data
[
'supplierCodes'
]
=
$supplierCodes
;
return
$this
->
view
(
'
上架
有效期配置'
);
return
$this
->
view
(
'
商品
有效期配置'
);
}
}
app/Http/Services/SkuService.php
View file @
221d6b83
...
...
@@ -364,12 +364,18 @@ class SkuService
}
//设置上架有效期
public
function
setSupplierSkuCpTimeLimit
(
$setType
,
$supplierGroup
,
$supplierCode
,
$
dayType
,
$cpTimeDay
)
public
function
setSupplierSkuCpTimeLimit
(
$setType
,
$supplierGroup
,
$supplierCode
,
$
cpTimeData
)
{
$dayType
=
$cpTimeData
[
'day_type'
];
$cpTimeDay
=
(
int
)
$cpTimeData
[
'cp_time_day'
];
$futuresDayType
=
$cpTimeData
[
'futures_day_type'
];
$futuresCpTimeDay
=
(
int
)
$cpTimeData
[
'futures_cp_time_day'
];
if
(
$dayType
==
2
)
{
$cpTimeDay
=
-
1
;
}
$cpTimeDay
=
(
int
)
$cpTimeDay
;
if
(
$futuresDayType
==
2
)
{
$futuresCpTimeDay
=
-
1
;
}
$redis
=
new
RedisModel
();
//批量设置
if
(
$setType
==
1
)
{
...
...
@@ -379,24 +385,23 @@ class SkuService
foreach
(
$supplierIds
as
$supplierIdList
)
{
$supplierIdList
=
array_values
(
$supplierIdList
);
//先去批量设置过期时间限制天数
$result
=
SupplierChannelModel
::
whereIn
(
'supplier_id'
,
$supplierIdList
)
->
update
([
'cp_time_day'
=>
$cpTimeDay
SupplierChannelModel
::
whereIn
(
'supplier_id'
,
$supplierIdList
)
->
update
([
'cp_time_day'
=>
$cpTimeDay
,
'futures_cp_time_day'
=>
$futuresCpTimeDay
,
]);
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
;
$ruler
[
'upload_futures_goods_validity_period'
]
=
$futuresCpTimeDay
;
$ruler
=
json_encode
(
$ruler
);
$redis
->
hset
(
'supplier_sku_upload_ruler_v2'
,
$supplierId
,
$ruler
);
}
$cpTimeDayStr
=
$cpTimeDay
==
-
1
?
'无限制'
:
$cpTimeDay
;
(
new
LogService
())
->
BatchAddIgnoreAuditLogs
(
$supplierIdList
,
LogModel
::
UPDATE_OPERATE
,
'批量配置供应商sku上架有效期'
,
'上架有效期修改为'
.
$cpTimeDayStr
.
'天'
);
(
new
LogService
())
->
BatchAddIgnoreAuditLogs
(
$supplierIdList
,
LogModel
::
UPDATE_OPERATE
,
'批量配置供应商sku上架有效期'
,
'上架有效期修改为'
.
$cpTimeDayStr
.
'天
,期货有效期修改为'
.
$futuresCpTimeDay
.
'天
'
);
}
}
...
...
@@ -408,19 +413,24 @@ class SkuService
$supplierId
=
$supplier
[
'supplier_id'
];
//先去批量设置过期时间限制天数
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'cp_time_day'
=>
$cpTimeDay
'cp_time_day'
=>
$cpTimeDay
,
'futures_cp_time_day'
=>
$futuresCpTimeDay
,
]);
$originDays
=
'[ ]'
;
$originDay
=
'[ ]'
;
$originFuturesDay
=
'[ ]'
;
$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
.
'天'
:
'[ ]'
;
$originDay
=
array_get
(
$ruler
,
'upload_validity_period'
);
$originDay
=
$originDay
?
$originDay
.
'天'
:
'[ ]'
;
$originFuturesDay
=
array_get
(
$ruler
,
'upload_futures_goods_validity_period'
);
$originFuturesDay
=
$originFuturesDay
?
$originFuturesDay
.
'天'
:
'[ ]'
;
}
$ruler
[
'upload_validity_period'
]
=
$cpTimeDay
;
$ruler
[
'upload_futures_goods_validity_period'
]
=
$futuresCpTimeDay
;
(
new
SupplierService
())
->
saveSkuCpTimeRulerToRedis
(
$supplierId
,
$ruler
);
$cpTimeDay
=
$cpTimeDay
==
-
1
?
'无限制'
:
$cpTimeDay
;
(
new
LogService
())
->
AddIgnoreAuditCheckLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'批量配置供应商sku上架有效期'
,
'上架有效期修由'
.
$originDay
s
.
'改为'
.
$c
pTimeDay
.
'天'
);
(
new
LogService
())
->
AddIgnoreAuditCheckLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'批量配置供应商sku上架有效期'
,
'上架有效期修由'
.
$originDay
.
'改为'
.
$cpTimeDay
.
'天,期货有效期由'
.
$originFuturesDay
.
'改为'
.
$futuresC
pTimeDay
.
'天'
);
}
}
}
...
...
app/Http/Services/SupplierService.php
View file @
221d6b83
...
...
@@ -60,6 +60,7 @@ class SupplierService
}
//保存供应商信息的方法,逻辑很多,需要多多注意
public
function
saveSupplier
(
$channel
)
{
$supplierTransformer
=
new
SupplierTransformer
();
...
...
@@ -75,7 +76,10 @@ class SupplierService
$oldSupplier
=
$model
->
where
(
'supplier_id'
,
$channel
[
'supplier_id'
])
->
first
();
$oldSupplier
=
$supplierTransformer
->
transformInfo
(
$oldSupplier
);
}
//判断是否要审核,默认是要审核的
$needAudit
=
true
;
//走事务
$supplierId
=
DB
::
connection
(
'web'
)
->
transaction
(
function
()
use
(
$channel
,
$model
,
$oldSupplier
,
&
$needAudit
)
{
...
...
@@ -267,6 +271,13 @@ class SupplierService
$oldCustomerTags
);
}
//新增供应商的话,还要去初始化有效期
if
(
empty
(
$channel
[
'supplier_id'
]))
{
//初始化有效期
$this
->
initialCpTimeDays
(
$supplierId
,
$channel
[
'supplier_group'
]);
}
//重新生成外部显示的编码
$this
->
generateSupplierSn
(
$supplierId
,
$channel
[
'supplier_group'
]);
//保存和搜索相关的标签情况
...
...
@@ -407,6 +418,29 @@ class SupplierService
$redis
->
hset
(
'supplier_sku_upload_ruler_v2'
,
$supplierId
,
$ruler
);
}
//初始化过期天数限制
public
function
initialCpTimeDays
(
$supplierId
,
$supplierGroup
)
{
$cpTimeDay
=
7
;
$futuresCpTimeDay
=
365
;
if
(
$supplierGroup
==
SupplierChannelModel
::
SUPPLIER_GROUP_ORIGINAL
)
{
$futuresCpTimeDay
=
$cpTimeDay
=
-
1
;
}
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'cp_time_day'
=>
$cpTimeDay
,
'futures_cp_time_day'
=>
$futuresCpTimeDay
,
]);
$redis
=
new
RedisModel
();
$ruler
=
$redis
->
hget
(
'supplier_sku_upload_ruler_v2'
,
$supplierId
);
if
(
$ruler
)
{
$ruler
=
json_decode
(
$ruler
,
true
);
}
$ruler
[
'upload_validity_period'
]
=
$cpTimeDay
;
$ruler
[
'upload_futures_goods_validity_period'
]
=
$futuresCpTimeDay
;
$ruler
=
json_encode
(
$ruler
);
$redis
->
hset
(
'supplier_sku_upload_ruler_v2'
,
$supplierId
,
$ruler
);
}
public
function
getAddress
(
$supplierId
)
{
...
...
app/Http/Validators/SupplierValidator.php
View file @
221d6b83
...
...
@@ -177,7 +177,7 @@ class SupplierValidator
//这里的校验是当供应商性质为7(混合分销商)的时候,代理证的有效期不能为空
foreach
(
$attachmentFields
as
$key
=>
$attachmentField
)
{
if
(
$attachmentField
==
'proxy_certificate'
&&
empty
(
$attachmentPeriods
[
$key
]))
{
$errorMessageList
[]
=
'
供应商性质为混合分销商时,
附件中代理证的有效期为必填,请检查对应代理证的附件有效期'
;
$errorMessageList
[]
=
'附件中代理证的有效期为必填,请检查对应代理证的附件有效期'
;
}
}
...
...
@@ -203,7 +203,7 @@ class SupplierValidator
}
if
(
$validateData
[
'supplier_type'
]
==
SupplierChannelModel
::
SUPPLIER_TYPE_OFFICIAL
&&
!
in_array
(
$validateData
[
'supplier_group'
],
[
SupplierChannelModel
::
SUPPLIER_
TYPE_OFFICI
AL
,
SupplierChannelModel
::
SUPPLIER_GROUP_PROXY
]))
{
[
SupplierChannelModel
::
SUPPLIER_
GROUP_ORIGIN
AL
,
SupplierChannelModel
::
SUPPLIER_GROUP_PROXY
]))
{
if
(
!
in_array
(
'quality_assurance_agreement'
,
$attachmentFields
))
{
$errorMessageList
[]
=
'供应商为正式供应商,品质保证协议必须上传 (代理商跟原厂类型除外) '
;
}
...
...
app/Http/routes.php
View file @
221d6b83
...
...
@@ -79,11 +79,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
$redis
=
\Illuminate\Support\Facades\Redis
::
connection
(
'spu'
);
dd
(
$redis
->
hget
(
'spu'
,
2168984725448887508
));
\App\Model\SupplierChannelModel
::
where
(
'supplier_id'
,
15385
)
->
update
([
'supplier_name'
=>
'Information And Communication Technology Group (Hongkong) Co., Limited'
]);
// (new \App\Http\Services\SupplierService())->initialCpTimeDays(15307, 5);
// (new \App\Http\Services\DataService())->initSkuRulers();
// (new \App\Http\Services\DataService())->initialMainBrandsLimit();
...
...
app/Model/SupplierChannelModel.php
View file @
221d6b83
...
...
@@ -34,8 +34,8 @@ class SupplierChannelModel extends Model
const
SYNC_UNITED_STATUS_OK
=
1
;
//供应商类型
const
SUPPLIER_GROUP_
ORIGINAL
=
1
;
//原厂
const
SUPPLIER_GROUP_
PROXY
=
4
;
//代理
const
SUPPLIER_GROUP_
PROXY
=
1
;
//代理
const
SUPPLIER_GROUP_
ORIGINAL
=
4
;
//原厂
const
SUPPLIER_GROUP_MIX
=
7
;
//混合分销商
//供应商地区
...
...
resources/views/script/SetSupplierSkuCpTimeLimitScript.blade.php
View file @
221d6b83
...
...
@@ -56,6 +56,17 @@
}
});
form
.
on
(
'select(futures_day_type)'
,
function
(
data
)
{
console
.
log
(
data
.
value
)
if
(
data
.
value
===
'2'
)
{
$
(
'#futures_cp_time_day'
).
attr
(
'disabled'
,
true
);
$
(
'#futures_cp_time_day'
).
addClass
(
'layui-disabled'
);
}
else
{
$
(
'#futures_cp_time_day'
).
attr
(
'disabled'
,
false
);
$
(
'#futures_cp_time_day'
).
removeClass
(
'layui-disabled'
);
}
});
form
.
on
(
'submit(cancel)'
,
function
(
data
)
{
admin
.
closeThisDialog
();
});
...
...
resources/views/script/SkuListScript.blade.php
View file @
221d6b83
...
...
@@ -441,7 +441,7 @@
type
:
2
,
content
:
'/sku/SetSupplierSkuCpTimeLimit?view=iframe'
,
area
:
[
'800px'
,
'600px'
],
title
:
'
上架
有效期配置'
,
title
:
'
商品
有效期配置'
,
end
:
function
()
{
}
});
...
...
resources/views/web/SetSupplierSkuCpTimeLimit.blade.php
View file @
221d6b83
...
...
@@ -17,7 +17,7 @@
config('fixed.SupplierGroup'),['required'=>true,'width'=>'150px']) !!}
</div>
</div>
<div
class=
"layui-form-item"
style=
"display: none"
id=
"supplier_code_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('supplier_code','供应商编码',null,
...
...
@@ -26,7 +26,8 @@
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
style=
"width: 150px"
><span
class=
"require"
></span>
上架有效期配置
</label>
<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"
...
...
@@ -41,6 +42,23 @@
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
style=
"width: 150px"
><span
class=
"require"
></span>
期货有效期配置
</label>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"futures_cp_time_day"
id=
"futures_cp_time_day"
placeholder=
"(天数)"
class=
"layui-input"
value=
""
>
</div>
</div>
<div
class=
"layui-inline"
>
<select
name=
"futures_day_type"
lay-filter=
"futures_day_type"
>
<option
value=
"1"
>
自定义
</option>
<option
value=
"2"
>
无限制
</option>
</select>
</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=
"setSupplierSkuCpTimeLimit"
>
确认
...
...
resources/views/web/SkuList.blade.php
View file @
221d6b83
...
...
@@ -38,7 +38,7 @@
<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>
<button type="
button
" class="
layui
-
btn
layui
-
btn
-
sm
" id="
set_sku_cp_time_ruler
">
商品
有效期配置</button>
@endif
@endif
</div>
...
...
vendor/_laravel_idea/_ide_helper_facades.php
View file @
221d6b83
This diff is collapsed.
Click to expand it.
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