Reply.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\admin\model\shopro\wechat;
  3. use app\admin\model\shopro\Common;
  4. use traits\model\SoftDelete;
  5. class Reply extends Common
  6. {
  7. use SoftDelete;
  8. protected $deleteTime = 'deletetime';
  9. protected $name = 'shopro_wechat_reply';
  10. // 追加属性
  11. protected $append = [
  12. 'type_text',
  13. 'group_text',
  14. 'status_text',
  15. ];
  16. public function getKeywordsAttr($value, $data)
  17. {
  18. if (!empty($value)) {
  19. return explode(',', $value);
  20. }
  21. return [];
  22. }
  23. public function setKeywordsAttr($value, $data)
  24. {
  25. if (!empty($value)) {
  26. return implode(',', $value);
  27. }
  28. return null;
  29. }
  30. /**
  31. * 状态列表
  32. *
  33. * @return array
  34. */
  35. public function typeList()
  36. {
  37. return ['text' => '文字', 'link' => '链接', 'image' => '图片', 'voice' => '语音', 'video' => '视频', 'news' => '图文消息'];
  38. }
  39. /**
  40. * 通用类型获取器
  41. *
  42. * @param string $value
  43. * @param array $data
  44. * @return string
  45. */
  46. public function getGroupTextAttr($value, $data)
  47. {
  48. $list = ['keywords' => '关键词回复', 'subscribe' => '关注回复', 'default' => '默认回复'];
  49. $value = $value ?: ($data['group'] ?? null);
  50. return isset($list[$value]) ? $list[$value] : '';
  51. }
  52. }