Merge branch 'feature/fin' into develop
This commit is contained in:
@@ -40,7 +40,7 @@ class FinPaymentApply extends Model
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'apply_no', 'doc_user_id', 'sales_user_id', 'corp_id', 'account_id', 'payment_account', 'payment_entity', 'entity_type', 'currency_id', 'amount', 'swift', 'remit_bank', 'country_id', 'remitter', 'exchange_rate', 'total_amount_cny', 'voucher_file', 'voucher_name', 'submit_files','receipt_id','claimed_at', 'created_at', 'updated_at'];
|
||||
protected $fillable = ['id', 'apply_no', 'doc_user_id', 'sales_user_id', 'corp_id', 'account_id', 'payment_account', 'payment_entity', 'entity_type', 'currency_id', 'amount', 'swift', 'remit_bank', 'country_id', 'remitter', 'exchange_rate', 'total_amount_cny', 'voucher_file', 'voucher_name', 'submit_files','receipt_id','claimed_at','warn', 'created_at', 'updated_at', 'claimed_by',];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
|
||||
@@ -174,11 +174,11 @@ class FinPaymentApplyService
|
||||
// 构建查询
|
||||
$query = $this->modelClass::where($where);
|
||||
|
||||
// 应用是否有关联收款记录的筛选
|
||||
// 是否已关联收款记录的筛选
|
||||
$correlation = $param['correlation']??'';
|
||||
if ($correlation === 'receipt') {
|
||||
if ($correlation === 'receipt') { //已关联
|
||||
$query->whereHas('receipt');
|
||||
} elseif ($correlation === 'unbind') {
|
||||
} elseif ($correlation === 'unbind') { //未关联
|
||||
$query->whereDoesntHave('receipt');
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ class FinPaymentApplyService
|
||||
return $query->paginate($limit, ['*'], 'page', $page);
|
||||
}
|
||||
|
||||
// 计算七天前的时间戳
|
||||
// 计算十天前的时间戳
|
||||
$sevenDaysAgo = time() - (10 * 24 * 60 * 60);
|
||||
|
||||
// 构建相似度排序逻辑
|
||||
@@ -197,8 +197,18 @@ class FinPaymentApplyService
|
||||
$similarityOrder[] = "CASE WHEN account_id = {$param['account_id']} THEN 0 ELSE 1 END";
|
||||
}
|
||||
|
||||
if (isset($param['country_id']) && !empty($param['country_id'])) {
|
||||
$similarityOrder[] = "CASE WHEN country_id = {$param['country_id']} THEN 0 ELSE 1 END";
|
||||
if (isset($param['currency_id']) && !empty($param['currency_id'])) {
|
||||
$similarityOrder[] = "CASE WHEN currency_id = {$param['currency_id']} THEN 0 ELSE 1 END";
|
||||
}
|
||||
|
||||
if (isset($param['remitter']) && !empty($param['remitter'])) {
|
||||
$similarityOrder[] = "CASE WHEN remitter = {$param['remitter']} THEN 0 ELSE 1 END";
|
||||
}
|
||||
|
||||
if (isset($param['amount']) && !empty($param['amount'])) {
|
||||
$amount = (float)$param['amount'];
|
||||
$similarityOrder[] = "ABS(amount - {$amount}) ASC";
|
||||
$similarityOrder[] = "CASE WHEN (ABS(amount - {$amount}) / {$amount} * 100) <= 5 THEN 0 ELSE 1 END";
|
||||
}
|
||||
|
||||
if (isset($param['keyword']) && $param['keyword']) {
|
||||
@@ -206,11 +216,6 @@ class FinPaymentApplyService
|
||||
$similarityOrder[] = "CASE WHEN remitter LIKE '%{$keyword}%' THEN 0 ELSE 1 END";
|
||||
}
|
||||
|
||||
if (isset($param['amount']) && !empty($param['amount'])) {
|
||||
$amount = (float)$param['amount'];
|
||||
$similarityOrder[] = "ABS(amount - {$amount})";
|
||||
}
|
||||
|
||||
// 构建排序SQL
|
||||
$orderByClause = "";
|
||||
if (!empty($similarityOrder)) {
|
||||
|
||||
@@ -291,7 +291,7 @@ class FinReceiptService
|
||||
$id = $request->input('id');
|
||||
$data = $this->preProcess(ucfirst($scene), $data, $request);
|
||||
$config = $this->buildQueryConfig($request, $scene);
|
||||
FinPaymentApply::where('id', $payment_apply_id)->update(['receipt_id' => $id, 'claimed_at' => time()]);
|
||||
FinPaymentApply::where('id', $payment_apply_id)->update(['receipt_id' => $id, 'claimed_at' => time(), 'claimed_by' => $request->user->uid]);
|
||||
|
||||
//折让金额
|
||||
$payment = FinPaymentApply::where('id', $payment_apply_id)->first();
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>邮箱提醒</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333333;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.email-container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.header {
|
||||
padding: 20px;
|
||||
background-color: #0056b3;
|
||||
color: white;
|
||||
text-align: center;
|
||||
}
|
||||
.content {
|
||||
padding: 20px;
|
||||
}
|
||||
.button {
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
background-color: #0056b3;
|
||||
color: white !important;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
font-weight: bold;
|
||||
margin: 10px 0;
|
||||
}
|
||||
.footer {
|
||||
padding: 15px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #777777;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
@media only screen and (max-width: 480px) {
|
||||
.email-container {
|
||||
width: 100%;
|
||||
}
|
||||
.button {
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!--[if mso]>
|
||||
<style type="text/css">
|
||||
.button {
|
||||
background-color: #0056b3 !important;
|
||||
color: white !important;
|
||||
}
|
||||
</style>
|
||||
<![endif]-->
|
||||
|
||||
<table class="email-container" width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
|
||||
<tr>
|
||||
<td class="header">
|
||||
<h1>付款单提醒</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="content">
|
||||
<p>您好,</p>
|
||||
<p>您有新的付款单待处理。请及时查看:</p>
|
||||
|
||||
<ul>
|
||||
<li>付款单编号:{{code}}</li>
|
||||
<li>付款主体:{{payment_entity}}</li>
|
||||
<li>问题描述:{{content}}</li>
|
||||
{{reply}}
|
||||
</ul>
|
||||
|
||||
<p>请点击下方按钮立即查看详情:</p>
|
||||
|
||||
<div style="text-align: center;">
|
||||
<a href="https://x.hnxinyouhe.com" class="button" style="color: white; text-decoration: none;">立即查看</a>
|
||||
</div>
|
||||
|
||||
<!--<p>如果您未请求此操作,请忽略此邮件或联系我们的客服团队。</p>-->
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="footer">
|
||||
<p>© 2025 河南新友合科技有限公司. 保留所有权利。</p>
|
||||
<p>这是系统自动发送的邮件,请勿直接回复。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
+2
-1
@@ -180,7 +180,8 @@ if (!function_exists('tplUrl')) {
|
||||
{
|
||||
$urlArray = [
|
||||
'email' => 'common/utils/scaffold/templates/Email.stub',
|
||||
'work_order' => 'common/utils/scaffold/templates/workOrder.stub'
|
||||
'work_order' => 'common/utils/scaffold/templates/workOrder.stub',
|
||||
'payment_files' => 'common/utils/scaffold/templates/paymentFiles.stub',
|
||||
];
|
||||
return $urlArray[$tplKey];
|
||||
}
|
||||
|
||||
+42
-2
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace app\process;
|
||||
|
||||
use app\common\model\FinPaymentApply;
|
||||
use app\common\model\User;
|
||||
use app\crm\model\Customer;
|
||||
use support\Log;
|
||||
use Workerman\Crontab\Crontab;
|
||||
@@ -11,7 +13,7 @@ class Task
|
||||
|
||||
public function onWorkerStart()
|
||||
{
|
||||
// 每半小时执行一次
|
||||
// 每半小时执行一次,通知待跟进客户
|
||||
new Crontab('0 */30 * * * *', function(){
|
||||
echo date('Y-m-d H:i:s') . "\n";
|
||||
Log::info('send follow start',[time()]);
|
||||
@@ -41,7 +43,45 @@ class Task
|
||||
$item->save();
|
||||
}
|
||||
|
||||
Log::info('send follow start',[time()]);
|
||||
Log::info('send follow end',[time()]);
|
||||
});
|
||||
|
||||
// 检查入账资料是否提交
|
||||
new Crontab('* */70 * * * *', function () {
|
||||
$G = date('G');
|
||||
if ($G > 22 || $G < 8) {
|
||||
return;
|
||||
}
|
||||
Log::info('fin_payment_apply submit_files start', [time()]);
|
||||
$orWhere = [
|
||||
['submit_files', '=', '[]'],
|
||||
['submit_files', '=', ''],
|
||||
];
|
||||
$where = [
|
||||
['warn', '<', 2],
|
||||
['created_at', '>', time() - 60 * 60 * 48],
|
||||
['created_at', '<', time() - 60 * 60 * 24],
|
||||
];
|
||||
$payment = FinPaymentApply::where($where)->orWhere($orWhere)->orderBy('id', 'desc')->get();
|
||||
foreach ($payment as $item) {
|
||||
Log::info('fin_payment_apply submit_files ', [$item->toArray()]);
|
||||
$notice = [
|
||||
'code' => $item->apply_no,
|
||||
'payment_entity' => $item->payment_entity ?? $item->remitter,
|
||||
'content' => '认领收款单后请在24小时内提交入账资料',
|
||||
'reply' => '',
|
||||
];
|
||||
$email = [];
|
||||
$email[] = User::where('id', $item->claimed_by)->value('email');
|
||||
$email[] = User::where('id', $item->doc_user_id)->value('email');
|
||||
$email = array_unique($email);
|
||||
\app\common\utils\email\MailSend::send($email, '【XYH】付款记录', replaceTpl($notice, 'payment_files'));
|
||||
|
||||
$item->warn = ++$item->warn;
|
||||
$item->save();
|
||||
}
|
||||
|
||||
Log::info('fin_payment_apply submit_files end', [time()]);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user