UserCancelServices.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\services\user;
  12. use app\dao\user\UserCancelDao;
  13. use app\services\BaseServices;
  14. use app\services\kefu\service\StoreServiceServices;
  15. use app\services\wechat\WechatUserServices;
  16. use crmeb\services\CacheService;
  17. class UserCancelServices extends BaseServices
  18. {
  19. protected $status = ['待审核', '已通过', '已拒绝'];
  20. /**
  21. * UserExtractServices constructor.
  22. * @param UserCancelDao $dao
  23. */
  24. public function __construct(UserCancelDao $dao)
  25. {
  26. $this->dao = $dao;
  27. }
  28. /**
  29. * 提交用户注销
  30. * @param $userInfo
  31. * @return mixed
  32. */
  33. public function SetUserCancel($uid)
  34. {
  35. /** @var UserServices $userServices */
  36. $userServices = app()->make(UserServices::class);
  37. /** @var WechatUserServices $wechatUserServices */
  38. $wechatUserServices = app()->make(WechatUserServices::class);
  39. /** @var StoreServiceServices $ServiceServices */
  40. $ServiceServices = app()->make(StoreServiceServices::class);
  41. $userServices->update($uid, ['is_del' => 1]);
  42. $userServices->update(['spread_uid' => $uid], ['spread_uid' => 0, 'spread_time' => 0]);
  43. $wechatUserServices->update(['uid' => $uid], ['is_del' => 1]);
  44. $ServiceServices->delete(['uid' => $uid]);
  45. $user = $userServices->getUserInfo($uid);
  46. //自定义事件-用户注销
  47. event('CustomEventListener', ['user_cancel', [
  48. 'uid' => $uid,
  49. 'nickname' => $user['nickname'],
  50. 'phone' => $user['phone'],
  51. 'add_time' => date('Y-m-d H:i:s', $user['add_time']),
  52. 'cancel_time' => date('Y-m-d H:i:s'),
  53. 'user_type' => $user['user_type'],
  54. ]]);
  55. return true;
  56. }
  57. /**
  58. * 获取注销列表
  59. * @param $where
  60. * @return array
  61. */
  62. public function getCancelList($where)
  63. {
  64. [$page, $limit] = $this->getPageValue();
  65. $list = $this->dao->getList($where, $page, $limit);
  66. foreach ($list as &$item) {
  67. $item['add_time'] = date('Y-m-d H:i:s', $item['add_time']);
  68. $item['up_time'] = $item['up_time'] != 0 ? date('Y-m-d H:i:s', $item['add_time']) : '';
  69. $item['status'] = $this->status[$item['status']];
  70. }
  71. $count = $this->dao->count($where);
  72. return compact('list', 'count');
  73. }
  74. /**
  75. * 备注
  76. * @param $id
  77. * @param $mark
  78. * @return mixed
  79. */
  80. public function serMark($id, $mark)
  81. {
  82. return $this->dao->update($id, ['remark' => $mark]);
  83. }
  84. }