Files
OMS/app/taoexlib/lib/sms/event/o2oship.php
2025-12-28 23:13:25 +08:00

118 lines
4.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Copyright © ShopeX http://www.shopex.cn. All rights reserved.
* See LICENSE file for license details.
*/
/**
* @description 门店配送短信触发事件
* @access public
* @param void
* @return void
*/
class taoexlib_sms_event_o2oship extends taoexlib_sms_event_abstract implements taoexlib_sms_event_interface
{
/**
*
* 短信模板标题
* @var string
*/
protected $_tmplTitle = '门店配送提醒';
/**
*
* 短信模板内容
* @var string
*/
protected $_tmplContent = '尊敬的用户{收货人},您的包裹已到达{门店名称},门店联系电话{门店联系电话},请耐心等待,我们会尽快为您进行配送,请凭借提货单{提货单}和校验码{校验码}进行签收, 谢谢!{短信签名}';
/**
*
* 短信模板变量
* @var array
*/
protected function getTmplVariables(){
return array(
array('id' => 'shouhuoren', 'name' => '收&nbsp;&nbsp;获&nbsp;&nbsp;人', 'value' => '{收货人}','br'=>''),
array('id' => 'tihuodan', 'name' => '提&nbsp;&nbsp;货&nbsp;&nbsp;单', 'value' => '{提货单}','br'=>'<br>'),
array('id' => 'jiaoyanma', 'name' => '校&nbsp;&nbsp;验&nbsp;&nbsp;码', 'value' => '{校验码}','br'=>''),
array('id' => 'mendianmingcheng', 'name' => '门店名称', 'value' => '{门店名称}','br'=>'<br>'),
array('id' => 'mendianlianxidianhua', 'name' => '门店联系电话', 'value' => '{门店联系电话}','br'=>''),
array('id'=>'msgsign','name'=>'短信签名','value'=>'{短信签名}','br'=>'<br>'),
array('id' => 'recovery', 'name' => '<font style="color:#f00">恢复默认</font>', 'value' => $this->_tmplContent,'br'=>'<br>','img'=>kernel::base_url(1).'/app/desktop/statics/bundle/afresh.gif'),
);
}
/**
* 检查Params
* @param mixed $params 参数
* @param mixed $error_msg error_msg
* @return mixed 返回验证结果
*/
public function checkParams(&$params, &$error_msg){
if(!$params["ship_mobile"] || !$params["ship_name"] || !$params["store_name"] || !$params["store_contact_tel"] || !$params["pickup_bn"]){
$error_msg = '收货人/联系电话/门店名称/门店电话/提货单不能为空';
return false;
}
return true;
}
/**
* formatContent
* @param mixed $params 参数
* @param mixed $sendParams 参数
* @param mixed $error_msg error_msg
* @return mixed 返回值
*/
public function formatContent($params, &$sendParams, &$error_msg){
//获取短信模板内容
$rule_sample_mdl = app::get('taoexlib')->model('sms_bind');
if(!$content){
$contentinfo = $rule_sample_mdl->getOtherSmsContent('o2oship');
if (!$contentinfo['content']) {
$error_msg = '短信模板未设置或未审核通过';
return false;
}else{
$content = $contentinfo['content'];
$sendParams["tplid"] = $contentinfo['tplid'];
}
}
//临时变量
$ship_name = $params['ship_name'];
$store_name = $params['store_name'];
$pickup_bn = $params['pickup_bn'];
$store_contact_tel = $params['store_contact_tel'];
//在关闭销单校验码状态下 不生成校验码 所以在发送日志和手机上收到的校验码显示“无”
$pickup_code = $params['pickup_code'];
$mobile_pkcode_display = '******';
if (!$pickup_code){
$pickup_code = "";
$mobile_pkcode_display = $pickup_code;
}
$helper = kernel::single('base_view_helper');
$sendParams['phones'] = $params["ship_mobile"];
$sendParams['replace'] = array(
'ship_name' => $helper->str_mosaic($ship_name,'*',true,0,1),
'pickup_bn' => $pickup_bn,
'pickup_code' => $pickup_code,
'store_name' => $store_name,
'msgsign' => "".$store_name."",
'store_contact_tel' => $store_contact_tel,
);
//替换签名 获取完整短信日志content
$find = array('{收货人}','{门店名称}','{短信签名}','{门店联系电话}','{提货单}','{校验码}');
$replace = array($helper->str_mosaic($ship_name,'*',true,0,1), $store_name, $sendParams['replace']['msgsign'], $store_contact_tel,'******',$mobile_pkcode_display);
//获取短信日志content
$sendParams['content'] = str_replace($find,$replace,$content);
return true;
}
}