- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明 Made-with: Cursor
40 lines
1.5 KiB
PHP
40 lines
1.5 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Author: ScottPan Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\services\user;
|
|
|
|
|
|
use app\services\BaseServices;
|
|
use app\services\wechat\WechatUserServices;
|
|
use think\facade\Log;
|
|
|
|
class CancelUserServices extends BaseServices
|
|
{
|
|
/**
|
|
* 注销用户账号
|
|
* @param int $uid 用户ID
|
|
* @return void
|
|
*/
|
|
public function cancelUser(int $uid)
|
|
{
|
|
try {
|
|
/** @var UserServices $userService */
|
|
$userService = app()->make(UserServices::class);
|
|
/** @var WechatUserServices $wechatUserServices */
|
|
$wechatUserServices = app()->make(WechatUserServices::class);
|
|
$userService->update(['spread_uid' => $uid], ['spread_uid' => 0]);// 清除用户与下级的关系
|
|
$userService->update($uid, ['spread_uid' => 0, 'integral' => 0, 'now_money' => 0]);//清除
|
|
$userService->update(['work_uid' => $uid], ['work_uid' => 0, 'work_userid' => '']);//清除企业微信上下级关系
|
|
$userService->destroy($uid);// 软删除用户
|
|
$wechatUserServices->update(['uid' => $uid], ['is_del' => 1, 'unionid' => '', 'openid' => time() . rand(1000, 9999)]);// 删除微信用户
|
|
// CancelUserJob::dispatch([$uid]);// 相关记录删除队列
|
|
|
|
} catch (\Throwable $e) {
|
|
Log::error('注销用户失败,失败原因:' . $e->getMessage());
|
|
}
|
|
|
|
}
|
|
}
|