123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class SendMessage extends Model
- {
- // 表名
- protected $table = 'send_message';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
-
- // 追加属性
- protected $append = [
- 'message_type_text',
- 'subscription_type_text',
- 'send_status_text',
- 'message_status_text',
- 'current_month_count_text',
- 'send_time_text',
- 'create_time_text',
- 'update_time_text',
- 'is_save_to_library_text'
- ];
- public function getMessageTypeList()
- {
- return ['1' => __('文本类型'),'2' => __('图文类型'),'3' => __('图片消息')];
- }
- public function getSubscriptionTypeList()
- {
- return ['1' => __('全部公众号'),'2' => __('指定公众号')];
- }
- public function getSendStatusList()
- {
- return [
- '1' => __('等待素材处理'),
- '2' => __('素材处理中'),
- '3' => __('素材处理完成待发送'),
- '4' => __('发送中'),
- '5' => __('发送完成'),
- '6' => __('发送失败(消息内容过期)'),
- '7' => __('已删除微信历史消息'),
- '8' => __('发送失败(接收人数小于2)')
- ];
- }
- public function getMessageStatusList()
- {
- return ['1' => __('有效'),'2' => __('失效'),'3' => __('已删除')];
- }
- public function getCurrentMonthCountList()
- {
- return ['1' => __('0次'),'2' => __('1次'),'3' => __('2次'),'4' => __('3次')];
- }
- public function getIsSaveToLibraryList()
- {
- return ['1' => __('是'),'2' => __('否')];
- }
- public function getMessageTypeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['message_type'];
- $list = $this->getMessageTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getSubscriptionTypeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['subscription_type'];
- $list = $this->getSubscriptionTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getSendStatusTextAttr($value, $data)
- {
- $value = $value ? $value : $data['send_status'];
- $list = $this->getSendStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getMessageStatusTextAttr($value, $data)
- {
- $value = $value ? $value : $data['message_status'];
- $list = $this->getMessageStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getCurrentMonthCountTextAttr($value, $data)
- {
- $value = $value ? $value : $data['current_month_count'];
- $list = $this->getCurrentMonthCountList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getSendTimeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['send_time'];
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getCreateTimeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['create_time'];
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getUpdateTimeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['update_time'];
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getIsSaveToLibraryTextAttr($value, $data)
- {
- $value = $value ? $value : $data['is_save_to_library'];
- $list = $this->getIsSaveToLibraryList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- protected function setSendTimeAttr($value)
- {
- return $value && !is_numeric($value) ? strtotime($value) : $value;
- }
- protected function setCreateTimeAttr($value)
- {
- return $value && !is_numeric($value) ? strtotime($value) : $value;
- }
- protected function setUpdateTimeAttr($value)
- {
- return $value && !is_numeric($value) ? strtotime($value) : $value;
- }
- }
|