61 lines
1.9 KiB
PHP
61 lines
1.9 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Server\H5;
|
||
|
|
|
||
|
|
use App\Models\Live\Anchor;
|
||
|
|
use App\Models\Server\AllianceMerchant;
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
class AllianceController extends Controller
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* 检查商户状态是不是联盟
|
||
|
|
* @param $merchant_id
|
||
|
|
*/
|
||
|
|
private function checkAlliance($merchant_id){
|
||
|
|
$anchor = Anchor::where('m_id',$merchant_id)->where('service_nature','alliance')
|
||
|
|
->first();
|
||
|
|
if($anchor){
|
||
|
|
return true;
|
||
|
|
}else{
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取联盟的成员
|
||
|
|
* @param Request $request
|
||
|
|
* @return \Illuminate\Http\JsonResponse|string
|
||
|
|
*/
|
||
|
|
public function getAllianceMerchantList(Request $request){
|
||
|
|
try {
|
||
|
|
$merchant_id = $request->merchant_id;
|
||
|
|
if(!$merchant_id){
|
||
|
|
return $this->failure('参数不全');
|
||
|
|
}
|
||
|
|
if(!$this->checkAlliance($merchant_id)){
|
||
|
|
return $this->failure('该商家不是联盟状态');
|
||
|
|
}
|
||
|
|
$no_page = $request->no_page;
|
||
|
|
$alliance_list = AllianceMerchant::where('alliance_merchants.alliance_id', $merchant_id)
|
||
|
|
->leftJoin('live_anchors', 'alliance_merchants.mch_id', 'live_anchors.m_id')
|
||
|
|
->leftJoin('merchant_infos', 'alliance_merchants.mch_id', 'merchant_infos.m_id')
|
||
|
|
->where('alliance_merchants.audit_type',2)
|
||
|
|
->select('live_anchors.*','merchant_infos.address');
|
||
|
|
if($no_page){
|
||
|
|
$alliance_list = $alliance_list->get();
|
||
|
|
}else {
|
||
|
|
$alliance_list = $alliance_list->paginate();
|
||
|
|
}
|
||
|
|
return $this->success('ok', $alliance_list);
|
||
|
|
}catch (\Exception $e){
|
||
|
|
$this->getError($e);
|
||
|
|
return $this->failure('服务器休息中,请稍后再试');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|