59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Services;
|
||
|
|
|
||
|
|
use App\Contracts\UserContract;
|
||
|
|
use App\Models\Server\MerchantUser;
|
||
|
|
use App\Models\User;
|
||
|
|
use App\Models\Wechat;
|
||
|
|
use App\Models\WrongInfoHistories;
|
||
|
|
use Exception;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* saas vip 用户相关服务类
|
||
|
|
*/
|
||
|
|
class SaasVipUserService
|
||
|
|
{
|
||
|
|
//根据saas用户id 匹配福恋用户id
|
||
|
|
public function matchFulinkUser($m_user_id,$mobile = null): int
|
||
|
|
{
|
||
|
|
$m_user = MerchantUser::where('id',$m_user_id)->first();
|
||
|
|
if(empty($m_user)) return 0;
|
||
|
|
|
||
|
|
$user_id = User::where('mobile',$m_user->mobile)->whereNotNull('mobile')->value('id');
|
||
|
|
if($user_id){
|
||
|
|
$user = User::find($user_id);
|
||
|
|
if(!$user) return 0;
|
||
|
|
return $user_id;
|
||
|
|
}
|
||
|
|
|
||
|
|
//下单的手机号
|
||
|
|
if(!$m_user->mobile && $mobile){
|
||
|
|
$user_id = User::where('mobile',$mobile)->whereNotNull('mobile')->value('id');
|
||
|
|
if($user_id){
|
||
|
|
$user = User::find($user_id);
|
||
|
|
if(!$user) return 0;
|
||
|
|
return $user_id;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$user_id = $m_user->user_id;
|
||
|
|
if($user_id){
|
||
|
|
$user = User::find($user_id);
|
||
|
|
if(!$user) return 0;
|
||
|
|
return $user_id;
|
||
|
|
}
|
||
|
|
|
||
|
|
// $wechat_user_id = Wechat::where('official_openid',$m_user->openid)->value('user_id');
|
||
|
|
// if($wechat_user_id) {
|
||
|
|
// return $wechat_user_id;
|
||
|
|
// }
|
||
|
|
|
||
|
|
// $wechat_user_id = Wechat::where('unionid',$m_user->unionid)->value('user_id');
|
||
|
|
// if($wechat_user_id) {
|
||
|
|
// return $wechat_user_id;
|
||
|
|
// }
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
}
|