KefuLangLogic.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\logic\kefu;
  20. use app\common\logic\BaseLogic;
  21. use app\common\model\KefuLang;
  22. /**
  23. * 客服话术逻辑
  24. * Class KefuLogic
  25. * @package app\adminapi\logic\kefu
  26. */
  27. class KefuLangLogic extends BaseLogic
  28. {
  29. /**
  30. * @notes 添加客服话术
  31. * @param array $params
  32. * @return KefuLang|\think\Model
  33. * @author 段誉
  34. * @date 2022/3/9 14:35
  35. */
  36. public static function add(array $params)
  37. {
  38. return KefuLang::create([
  39. 'title' => $params['title'],
  40. 'content' => $params['content'],
  41. 'sort' => $params['sort'] ?? 1,
  42. ]);
  43. }
  44. /**
  45. * @notes 编辑客服话术
  46. * @param array $params
  47. * @return KefuLang
  48. * @author 段誉
  49. * @date 2022/3/9 14:35
  50. */
  51. public static function edit(array $params)
  52. {
  53. return KefuLang::update([
  54. 'id' => $params['id'],
  55. 'title' => $params['title'],
  56. 'content' => $params['content'],
  57. 'sort' => $params['sort'],
  58. ]);
  59. }
  60. /**
  61. * @notes 删除客服话术
  62. * @param int $id
  63. * @return bool
  64. * @author 段誉
  65. * @date 2022/3/9 14:36
  66. */
  67. public static function del(int $id): bool
  68. {
  69. return KefuLang::destroy($id);
  70. }
  71. /**
  72. * @notes 获取客服话术详情
  73. * @param int $id
  74. * @return array
  75. * @author 段誉
  76. * @date 2022/3/9 14:37
  77. */
  78. public static function detail(int $id)
  79. {
  80. return KefuLang::findOrEmpty($id)->toArray();
  81. }
  82. }