This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop/source/application/common/service/Message.php

48 lines
1.3 KiB
PHP
Raw Normal View History

2020-04-25 22:20:29 +08:00
<?php
namespace app\common\service;
/**
* 消息通知服务
* Class Message
* @package app\common\service
*/
2020-04-25 22:53:20 +08:00
class Message extends Basics
2020-04-25 22:20:29 +08:00
{
/**
2020-04-25 22:53:20 +08:00
* 场景列表
* [场景名称] => [场景类]
* @var array
2020-04-25 22:20:29 +08:00
*/
2020-04-25 22:53:20 +08:00
private static $sceneList = [
// 订单支付成功
'order.payment' => 'app\common\service\message\order\Payment',
// 订单发货
'order.delivery' => 'app\common\service\message\order\Delivery',
// 订单退款
'order.refund' => 'app\common\service\message\order\Refund',
2020-04-25 22:20:29 +08:00
2020-04-25 22:53:20 +08:00
// 拼团进度通知
'sharing.active_status' => 'app\common\service\message\sharing\ActiveStatus',
2020-04-25 22:20:29 +08:00
2020-04-25 22:53:20 +08:00
// 分销商入驻通知
'dealer.apply' => 'app\common\service\message\dealer\Apply',
// 分销商提现通知
'dealer.withdraw' => 'app\common\service\message\dealer\Withdraw',
];
2020-04-25 22:20:29 +08:00
/**
2020-04-25 22:53:20 +08:00
* 发送消息通知
* @param string $sceneName 场景名称
* @param array $param 参数
2020-04-25 22:20:29 +08:00
* @return bool
*/
2020-04-25 22:53:20 +08:00
public static function send($sceneName, $param)
2020-04-25 22:20:29 +08:00
{
2020-04-25 22:53:20 +08:00
if (!isset(self::$sceneList[$sceneName]))
return false;
$className = self::$sceneList[$sceneName];
return class_exists($className) ? (new $className)->send($param) : false;
2020-04-25 22:20:29 +08:00
}
}