注销用户同时删除客服,并停止此用户的消息的发送

This commit is contained in:
evoxwht 2023-05-16 15:46:17 +08:00
parent 767b06c1b0
commit bbc4c92094
4 changed files with 19 additions and 7 deletions

View File

@ -14,6 +14,7 @@ namespace app\services\message\notice;
use app\jobs\TemplateJob;
use app\services\message\NoticeService;
use app\services\kefu\service\StoreServiceServices;
use app\services\user\UserServices;
use app\services\wechat\WechatUserServices;
use think\facade\Log;
@ -52,9 +53,13 @@ class WechatTemplateListService extends NoticeService
*/
public function getOpenidByUid(int $uid)
{
/** @var WechatUserServices $wechatServices */
$wechatServices = app()->make(WechatUserServices::class);
return $wechatServices->uidToOpenid($uid, 'wechat');
$isDel = app()->make(UserServices::class)->value(['uid' => $uid], 'is_del');
if ($isDel) {
$openid = '';
} else {
$openid = app()->make(WechatUserServices::class)->uidToOpenid($uid, 'wechat');
}
return $openid;
}
/**
@ -71,8 +76,10 @@ class WechatTemplateListService extends NoticeService
$this->isOpen = $this->noticeInfo['is_wechat'] === 1;
if ($this->isOpen) {
$openid = $this->getOpenidByUid($uid);
//放入队列执行
TemplateJob::dispatch('doJob', ['wechat', $openid, $this->noticeInfo['mark'], $data, $link, $color]);
if ($openid != '') {
//放入队列执行
TemplateJob::dispatch('doJob', ['wechat', $openid, $this->noticeInfo['mark'], $data, $link, $color]);
}
}
} catch (\Exception $e) {
Log::error($e->getMessage());

View File

@ -4,6 +4,7 @@ namespace app\services\user;
use app\dao\user\UserCancelDao;
use app\services\BaseServices;
use app\services\kefu\service\StoreServiceServices;
use app\services\wechat\WechatUserServices;
use crmeb\services\CacheService;
@ -31,9 +32,13 @@ class UserCancelServices extends BaseServices
$userServices = app()->make(UserServices::class);
/** @var WechatUserServices $wechatUserServices */
$wechatUserServices = app()->make(WechatUserServices::class);
/** @var StoreServiceServices $ServiceServices */
$ServiceServices = app()->make(StoreServiceServices::class);
$userServices->update($uid, ['is_del' => 1]);
$userServices->update(['spread_uid' => $uid], ['spread_uid' => 0, 'spread_time' => 0]);
$wechatUserServices->update(['uid' => $uid], ['is_del' => 1]);
$ServiceServices->delete(['uid' => $uid]);
return true;
}
/**

View File

@ -479,7 +479,7 @@ class RoutineServices extends BaseServices
if (!$userInfo || !isset($userInfo['purePhoneNumber'])) {
throw new ApiException(410079);
}
$uid = app()->make(WechatUserServices::class)->openidTouid($userInfoCong['openid']);
$uid = app()->make(WechatUserServices::class)->openidToUid($userInfoCong['openid']);
$userServices = app()->make(UserServices::class);
if ($userServices->count(['phone' => $userInfo['purePhoneNumber']])) {
throw new ApiException(410028);

View File

@ -83,7 +83,7 @@ class WechatUserServices extends BaseServices
* @param string $openidType
* @return mixed
*/
public function openidTouid($openid, $openidType = 'openid')
public function openidToUid($openid, string $openidType = 'openid')
{
$uid = $this->dao->value([[$openidType, '=', $openid], ['user_type', '<>', 'h5']], 'uid');
if (!$uid)