195 lines
5.0 KiB
PHP
195 lines
5.0 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Services;
|
||
|
|
|
||
|
|
use App\Models\CommunityActivity;
|
||
|
|
use App\Models\Consultation;
|
||
|
|
use App\Models\Course\Course;
|
||
|
|
use App\Models\MerchantShop;
|
||
|
|
use App\Models\Server\EvaluateList;
|
||
|
|
use App\Models\Server\MerchantAccount;
|
||
|
|
use App\Models\Server\MerchantEvaluate;
|
||
|
|
use App\Models\Server\MerchantService;
|
||
|
|
use App\Models\Server\SaasMemberLevel;
|
||
|
|
use App\Models\Server\SaasMemberVipGain;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* saas vip推广相关服务类
|
||
|
|
*/
|
||
|
|
class SaasVipSpreadService
|
||
|
|
{
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取对应的权益数据
|
||
|
|
* @param string $type
|
||
|
|
* @param $merchant_id
|
||
|
|
* @param $id
|
||
|
|
* @return null
|
||
|
|
*/
|
||
|
|
public function getGain(string $type = '', $merchant_id = null, $id = null)
|
||
|
|
{
|
||
|
|
if (empty($type)) {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return $this->$type($merchant_id,$id);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 活动
|
||
|
|
* @param $merchant_id
|
||
|
|
* @param $id
|
||
|
|
* @return mixed
|
||
|
|
*/
|
||
|
|
private function activity($merchant_id, $id)
|
||
|
|
{
|
||
|
|
$where = [
|
||
|
|
['class','=','one']
|
||
|
|
];
|
||
|
|
if ($merchant_id) {
|
||
|
|
$where[] = ['merchant_id', '=', $merchant_id];
|
||
|
|
}
|
||
|
|
if ($id) {
|
||
|
|
$where[] = ['id', '=', $id];
|
||
|
|
}
|
||
|
|
$data = CommunityActivity::where($where)
|
||
|
|
->orderBy('id', 'desc')
|
||
|
|
->first();
|
||
|
|
if($data){
|
||
|
|
$data->sku = json_decode($data->sku);
|
||
|
|
$data->merchant = MerchantAccount::with('anchorV2')->where('id',$data->merchant_id)->first();
|
||
|
|
}
|
||
|
|
return $data;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 咨询
|
||
|
|
* @param $merchant_id
|
||
|
|
* @param $id
|
||
|
|
* @return Consultation|Consultation[]|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|object
|
||
|
|
*/
|
||
|
|
private function consultation($merchant_id, $id)
|
||
|
|
{
|
||
|
|
$where = [];
|
||
|
|
if ($id) {
|
||
|
|
$where[] = ['id', '=', $id];
|
||
|
|
}
|
||
|
|
$data = Consultation::with('teacher')
|
||
|
|
->whereHas('teacher', function ($query) use ($merchant_id) {
|
||
|
|
if ($merchant_id) {
|
||
|
|
$query->where('merchant_id', $merchant_id);
|
||
|
|
}
|
||
|
|
})
|
||
|
|
->where($where)
|
||
|
|
->orderBy('id', 'desc')
|
||
|
|
->first();
|
||
|
|
if($data){
|
||
|
|
$data->merchant = MerchantAccount::with('anchorV2')->where('id',$data->teacher->merchant_id)->first();
|
||
|
|
}
|
||
|
|
return $data;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 课程
|
||
|
|
* @param $merchant_id
|
||
|
|
* @param $id
|
||
|
|
* @return mixed
|
||
|
|
*/
|
||
|
|
private function course($merchant_id, $id)
|
||
|
|
{
|
||
|
|
$where = [];
|
||
|
|
if ($merchant_id) {
|
||
|
|
$where[] = ['merchant_id', '=', $merchant_id];
|
||
|
|
}
|
||
|
|
if ($id) {
|
||
|
|
$where[] = ['id', '=', $id];
|
||
|
|
}
|
||
|
|
$data = Course::where($where)->orderBy('id', 'desc')->first();
|
||
|
|
if($data){
|
||
|
|
$data->merchant = MerchantAccount::with('anchorV2')->where('id',$data->merchant_id)->first();
|
||
|
|
}
|
||
|
|
return $data;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 测评
|
||
|
|
* @param $merchant_id
|
||
|
|
* @param $id
|
||
|
|
* @return mixed
|
||
|
|
*/
|
||
|
|
private function evaluation($merchant_id, $id)
|
||
|
|
{
|
||
|
|
$where = [];
|
||
|
|
if ($merchant_id) {
|
||
|
|
$where[] = ['merchant_id', '=', $merchant_id];
|
||
|
|
}
|
||
|
|
if ($id) {
|
||
|
|
$where[] = ['id', '=', $id];
|
||
|
|
}
|
||
|
|
$data = MerchantEvaluate::where($where)->orderBy('id','desc')->first();
|
||
|
|
if($data){
|
||
|
|
$data->merchant = MerchantAccount::with('anchorV2')->where('id',$data->merchant_id)->first();
|
||
|
|
}
|
||
|
|
return $data;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 服务
|
||
|
|
* @param $merchant_id
|
||
|
|
* @param $id
|
||
|
|
* @return mixed
|
||
|
|
*/
|
||
|
|
private function service($merchant_id, $id)
|
||
|
|
{
|
||
|
|
$where = [
|
||
|
|
['class','=','many']
|
||
|
|
];
|
||
|
|
if($merchant_id){
|
||
|
|
$where[] = ['merchant_id','=',$merchant_id];
|
||
|
|
}
|
||
|
|
if ($id) {
|
||
|
|
$where[] = ['id', '=', $id];
|
||
|
|
}
|
||
|
|
$data = CommunityActivity::where($where)
|
||
|
|
->orderBy('id', 'desc')
|
||
|
|
->first();
|
||
|
|
if($data){
|
||
|
|
$data->sku = json_decode($data->sku);
|
||
|
|
$data->merchant = MerchantAccount::with('anchorV2')->where('id',$data->merchant_id)->first();
|
||
|
|
}
|
||
|
|
return $data;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 福恋vip
|
||
|
|
* @param $merchant_id
|
||
|
|
* @param $id
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
private function vip($merchant_id, $id)
|
||
|
|
{
|
||
|
|
return [];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 商品
|
||
|
|
*/
|
||
|
|
private function shop($merchant_id, $id)
|
||
|
|
{
|
||
|
|
$where = [
|
||
|
|
];
|
||
|
|
if($merchant_id){
|
||
|
|
$where[] = ['merchant_id','=',$merchant_id];
|
||
|
|
}
|
||
|
|
if ($id) {
|
||
|
|
$where[] = ['id', '=', $id];
|
||
|
|
}
|
||
|
|
$data = MerchantShop::where($where)
|
||
|
|
->orderBy('id', 'desc')
|
||
|
|
->first();
|
||
|
|
if($data){
|
||
|
|
$data->sku = json_decode($data->sku);
|
||
|
|
$data->merchant = MerchantAccount::with('anchorV2')->where('id',$data->merchant_id)->first();
|
||
|
|
}
|
||
|
|
return $data;
|
||
|
|
}
|
||
|
|
}
|