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
a585c92d
authored
Jul 22, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
临时保存部分代码
parent
e9439ab9
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
170 additions
and
1 deletions
app/Console/Commands/SupplierRecallMailRemind.php
app/Console/Kernel.php
app/Http/Controllers/Api/SupplierContractApiController.php
app/Http/Transformers/SupplierContractTransformer.php
resources/views/script/SaveSupplierContractScript.blade.php
resources/views/script/SupplierContractListScript.blade.php
resources/views/web/SaveSupplierContract.blade.php
app/Console/Commands/SupplierRecallMailRemind.php
0 → 100644
View file @
a585c92d
<?php
namespace
App\Console\Commands
;
use
Carbon\Carbon
;
use
App\Model\RedisModel
;
use
Illuminate\Console\Command
;
use
Illuminate\Support\Facades\DB
;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierContractModel
;
use
App\Http\Services\MessageService
;
use
Illuminate\Support\Facades\Redis
;
use
App\Http\Services\AdminUserService
;
class
SupplierRecallMailRemind
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'supplier:recall_mail_remind'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'寄售召回期邮件提醒(提前30天、7天)'
;
public
function
handle
()
{
$today
=
Carbon
::
today
();
$contracts
=
SupplierContractModel
::
with
(
'supplier'
)
->
where
(
'recall_time'
,
'!='
,
0
)
->
get
();
$adminUserService
=
new
AdminUserService
();
$messageService
=
new
MessageService
();
$remindDays
=
[
30
,
7
];
foreach
(
$contracts
as
$contract
)
{
//判断有没有上架的sku,通过搜索接口查询
$map
[
'p'
]
=
1
;
$map
[
'offset'
]
=
200
;
$map
[
'canal'
]
=
$contract
->
supplier
->
supplier_code
;
$map
[
'goods_status'
]
=
1
;
$url
=
env
(
'ES_SKU_URL'
,
''
);
$map
[
'show_status'
]
=
1
;
$map
[
'no_rule'
]
=
1122
;
try
{
$url
=
base64_encode
(
$url
.
'?'
.
http_build_query
(
$map
));
$return
=
curl
(
config
(
'website.FootstoneCurlUrl'
)
.
$url
);
$data
=
json_decode
(
$return
,
true
);
if
(
isset
(
$data
[
'error_code'
])
&&
$data
[
'error_code'
]
==
0
)
{
$searchResult
=
$data
[
'data'
][
'goods_id'
];
$skuDataList
=
[];
$redis
=
new
RedisModel
();
$spuRedis
=
Redis
::
connection
(
'spu'
);
foreach
(
$searchResult
as
$goodsId
)
{
$sku
=
json_decode
(
$redis
->
hget
(
'sku'
,
$goodsId
),
true
);
if
(
empty
(
$sku
))
{
continue
;
}
$spu
=
json_decode
(
$spuRedis
->
hget
(
'spu'
,
$sku
[
'spu_id'
]),
true
);
//去获取标准品牌名称
$standardBrandId
=
$spu
[
's_brand_id'
];
$standardBrand
=
$redis
->
hget
(
'standard_brand'
,
$standardBrandId
);
if
(
empty
(
$standardBrand
))
{
continue
;
}
$skuDataList
[]
=
[
'spu_name'
=>
$spu
[
'spu_name'
],
'brand_name'
=>
$standardBrand
[
'brand_name'
],
'stock'
=>
$sku
[
'stock'
],
];
}
}
else
{
$searchResult
=
[];
}
}
catch
(
\Exception
$e
)
{
return
$e
->
getMessage
();
}
if
(
empty
(
$searchResult
))
{
continue
;
}
$recallDate
=
Carbon
::
createFromTimestamp
(
$contract
->
recall_time
);
$diff
=
$today
->
diffInDays
(
$recallDate
,
false
);
if
(
!
in_array
(
$diff
,
$remindDays
))
{
continue
;
}
$supplier
=
$contract
->
supplier
;
$supplierName
=
isset
(
$supplier
->
supplier_name
)
?
$supplier
->
supplier_name
:
''
;
$recallTimeStr
=
$recallDate
->
toDateString
();
// 获取采购员
$toEmails
=
[];
$ccEmails
=
[];
if
(
!
empty
(
$supplier
->
yunxin_channel_uid
))
{
$purchaseUser
=
$adminUserService
->
getAdminUserInfoByCodeId
(
$supplier
->
yunxin_channel_uid
);
if
(
$purchaseUser
&&
!
empty
(
$purchaseUser
->
email
))
{
$toEmails
[]
=
$purchaseUser
->
email
;
// 采购经理
$manager
=
null
;
if
(
!
empty
(
$purchaseUser
->
department_id
))
{
$manager
=
DB
::
table
(
'user_info'
)
->
where
(
'department_id'
,
$purchaseUser
->
department_id
)
->
where
(
'position_name'
,
'采购经理'
)
->
first
();
if
(
$manager
&&
!
empty
(
$manager
->
email
))
{
$ccEmails
[]
=
$manager
->
email
;
}
// 采购总监
$director
=
DB
::
table
(
'user_position'
)
->
where
(
'department_id'
,
$purchaseUser
->
department_id
)
->
where
(
'position_name'
,
'采购总监'
)
->
first
();
if
(
$director
)
{
$directorUser
=
DB
::
table
(
'user_info'
)
->
where
(
'position_id'
,
$director
->
position_id
)
->
first
();
if
(
$directorUser
&&
!
empty
(
$directorUser
->
email
))
{
$ccEmails
[]
=
$directorUser
->
email
;
}
}
}
}
}
// 邮件主题与内容
$subject
=
"【寄售召回提醒】距离召回期仅剩
{
$diff
}
天"
;
$content
=
"请及时提醒供应商召回寄售商品
\n
供应商名称:
{
$supplierName
}
\n
召回期:
{
$recallTimeStr
}
"
;
// 组装邮件数据
$data
=
[
'data'
=>
[
'title'
=>
$subject
,
'content'
=>
$content
,
]
];
// 发送邮件
foreach
(
$toEmails
as
$to
)
{
$messageService
->
sendMessage
(
'supplier_recall_remind'
,
$data
,
$to
,
true
);
}
foreach
(
$ccEmails
as
$cc
)
{
$messageService
->
sendMessage
(
'supplier_recall_remind'
,
$data
,
$cc
,
true
);
}
$this
->
info
(
"已发送提醒:供应商
{
$supplierName
}
,召回期
{
$recallTimeStr
}
,剩余
{
$diff
}
天"
);
}
}
}
app/Console/Kernel.php
View file @
a585c92d
...
...
@@ -18,6 +18,7 @@ class Kernel extends ConsoleKernel
Commands\RepairChannelUser
::
class
,
Commands\RemoveEmptyContact
::
class
,
Commands\SyncAllSupplierToErp
::
class
,
Commands\SupplierRecallMailRemind
::
class
,
];
/**
...
...
app/Http/Controllers/Api/SupplierContractApiController.php
View file @
a585c92d
...
...
@@ -34,6 +34,7 @@ class SupplierContractApiController extends Controller
'supplier_id'
,
'commission_rate'
,
'end_time'
,
'recall_time'
,
'check_date'
,
]);
...
...
app/Http/Transformers/SupplierContractTransformer.php
View file @
a585c92d
...
...
@@ -29,6 +29,7 @@ class SupplierContractTransformer
$contract
[
'update_time'
]
)
:
''
;
$contract
[
'valid_date'
]
=
date
(
'Y-m-d H:i:s'
,
$contract
[
'end_time'
]);
$contract
[
'recall_time'
]
=
$contract
[
'recall_time'
]
?
date
(
'Y-m-d H:i:s'
,
$contract
[
'recall_time'
])
:
''
;
}
unset
(
$contract
);
return
$list
;
...
...
resources/views/script/SaveSupplierContractScript.blade.php
View file @
a585c92d
...
...
@@ -16,6 +16,11 @@
type
:
'datetime'
});
laydate
.
render
({
elem
:
'#recall_time'
,
type
:
'datetime'
});
//初始化供应商编码下拉框
let
supplierSelect
=
xmSelect
.
render
({
el
:
'#supplier_id'
,
...
...
resources/views/script/SupplierContractListScript.blade.php
View file @
a585c92d
...
...
@@ -99,7 +99,13 @@
field
:
'valid_date'
,
title
:
'合同有效期'
,
align
:
'center'
,
width
:
280
width
:
150
},
{
field
:
'recall_time'
,
title
:
'召回期'
,
align
:
'center'
,
width
:
150
},
{
field
:
'check_date'
,
...
...
resources/views/web/SaveSupplierContract.blade.php
View file @
a585c92d
...
...
@@ -38,6 +38,14 @@
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
><span
class=
"require"
>
*
</span>
召回期
</label>
<div
class=
"layui-input-inline"
style=
"width: 150px;"
>
<input
type=
"text"
name=
"recall_time"
id=
"recall_time"
placeholder=
"召回期"
class=
"layui-input"
autocomplete=
"off"
value=
"{{ $contract['recall_time'] or '' }}"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
抽佣比率
</label>
<div
class=
"layui-input-inline"
style=
"position:relative"
>
...
...
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