79 lines
2.1 KiB
PHP
Executable File
79 lines
2.1 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\common\model;
|
|
|
|
/**
|
|
* 员工代发消息(企业群发)任务
|
|
*
|
|
* 企业群发 add_msg_template 的特性:
|
|
* - 必须以「员工身份」为 sender 代发,客户端显示为员工本人
|
|
* - 员工手机端会弹一次"发送确认",员工点确认后才真正送达客户;admin 后台无法强制送达
|
|
* - 返回的 msgid 可通过 get_group_msg_send_result 查询确认 / 送达结果
|
|
*
|
|
* 状态:
|
|
* 0=待提交、1=已提交等待员工确认、2=员工已确认发送、3=失败
|
|
*/
|
|
class QywxMsgSendTask extends BaseModel
|
|
{
|
|
protected $name = 'qywx_msg_send_task';
|
|
protected $autoWriteTimestamp = 'int';
|
|
|
|
public const STATUS_PENDING = 0;
|
|
public const STATUS_SUBMITTED = 1;
|
|
public const STATUS_SENT = 2;
|
|
public const STATUS_FAILED = 3;
|
|
|
|
public function getExternalUseridsAttr($value): array
|
|
{
|
|
if ($value === null || $value === '') {
|
|
return [];
|
|
}
|
|
$decoded = json_decode((string) $value, true);
|
|
return is_array($decoded) ? $decoded : [];
|
|
}
|
|
|
|
public function setExternalUseridsAttr($value): string
|
|
{
|
|
if (is_string($value)) {
|
|
return $value;
|
|
}
|
|
return json_encode($value ?? [], JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
public function getMsgPayloadAttr($value)
|
|
{
|
|
if ($value === null || $value === '') {
|
|
return [];
|
|
}
|
|
$decoded = json_decode((string) $value, true);
|
|
return is_array($decoded) ? $decoded : [];
|
|
}
|
|
|
|
public function setMsgPayloadAttr($value): string
|
|
{
|
|
if (is_string($value)) {
|
|
return $value;
|
|
}
|
|
return json_encode($value ?? [], JSON_UNESCAPED_UNICODE);
|
|
}
|
|
|
|
public function getFailListAttr($value)
|
|
{
|
|
if ($value === null || $value === '') {
|
|
return [];
|
|
}
|
|
$decoded = json_decode((string) $value, true);
|
|
return is_array($decoded) ? $decoded : [];
|
|
}
|
|
|
|
public function setFailListAttr($value): string
|
|
{
|
|
if (is_string($value)) {
|
|
return $value;
|
|
}
|
|
return json_encode($value ?? [], JSON_UNESCAPED_UNICODE);
|
|
}
|
|
}
|