You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/common/service/message/dealer/Apply.php

95 lines
3.1 KiB

11 months ago
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\service\message\dealer;
use app\common\service\message\Basics;
use app\common\model\store\Setting as SettingModel;
use app\common\enum\dealer\apply\ApplyStatus as ApplyStatusEnum;
/**
* 消息通知服务 [分销商入驻]
* Class Apply
* @package app\common\service\message\dealer
*/
class Apply extends Basics
{
/**
* 参数列表
* @var array
*/
protected $param = [
'apply' => [], // 申请记录
'user' => [], // 用户信息
];
/**
* 发送消息通知
* @param array $param
* @return mixed|void
* @throws \think\Exception
*/
public function send(array $param)
{
// 记录参数
$this->param = $param;
// 微信订阅消息通知用户
// $this->onSendWxSubMsg();
}
/**
* 微信订阅消息通知用户
* @return bool|mixed
* @throws \cores\exception\BaseException
* @throws \think\Exception
*/
private function onSendWxSubMsg()
{
$applyInfo = $this->param['apply'];
$userInfo = $this->param['user'];
// 获取订阅消息配置
$template = SettingModel::getItem('submsg', $this->storeId)['dealer']['apply'];
if (empty($template['template_id'])) {
return false;
}
// 发送订阅消息
return $this->sendWxSubMsg([
'touser' => $userInfo['open_id'],
'template_id' => $template['template_id'],
'page' => 'pages/dealer/index/index',
'data' => [
// 申请时间
$template['keywords'][0] => ['value' => $applyInfo['apply_time']],
// 审核状态
$template['keywords'][1] => ['value' => ApplyStatusEnum::data()[$applyInfo['apply_status']]['name']],
// 审核时间
$template['keywords'][2] => ['value' => $applyInfo['audit_time']],
// 备注信息
$template['keywords'][3] => ['value' => $this->getRemarkValue($applyInfo)],
]
]);
}
/**
* 备注信息
* @param $applyInfo
* @return string
*/
private function getRemarkValue($applyInfo)
{
$remark = '分销商入驻审核通知';
if ($applyInfo['apply_status'] == ApplyStatusEnum::REJECT) {
$remark .= "\n驳回原因:{$applyInfo['reject_reason']}";
}
return $this->getSubstr($remark);
}
}