diff --git a/app/common/model/FinPaymentApply.php b/app/common/model/FinPaymentApply.php index 82f81cb..0f4d157 100644 --- a/app/common/model/FinPaymentApply.php +++ b/app/common/model/FinPaymentApply.php @@ -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',]; /** * 不允许自动填充模型字段 diff --git a/app/common/service/FinReceiptService.php b/app/common/service/FinReceiptService.php index 48f9832..91db094 100644 --- a/app/common/service/FinReceiptService.php +++ b/app/common/service/FinReceiptService.php @@ -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(); diff --git a/app/common/utils/scaffold/templates/paymentFiles.stub b/app/common/utils/scaffold/templates/paymentFiles.stub new file mode 100644 index 0000000..6c9cded --- /dev/null +++ b/app/common/utils/scaffold/templates/paymentFiles.stub @@ -0,0 +1,103 @@ + + + + + + 邮箱提醒 + + + + + + + + + + + + + + + +
+

付款单提醒

+
+

您好,

+

您有新的付款单待处理。请及时查看:

+ +
    +
  • 付款单编号:{{code}}
  • +
  • 付款主体:{{payment_entity}}
  • +
  • 问题描述:{{content}}
  • + {{reply}} +
+ +

请点击下方按钮立即查看详情:

+ +
+ 立即查看 +
+ + +
+ + \ No newline at end of file diff --git a/app/functions.php b/app/functions.php index 7ae0d0a..075dfbf 100644 --- a/app/functions.php +++ b/app/functions.php @@ -179,7 +179,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]; } diff --git a/app/process/Task.php b/app/process/Task.php index 910b5ad..47dbb93 100644 --- a/app/process/Task.php +++ b/app/process/Task.php @@ -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()]); @@ -34,7 +36,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()]); }); }