152 lines
5.7 KiB
PHP
152 lines
5.7 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\CommunityActivity;
|
|
use App\Models\ConfigAdvertise;
|
|
use App\Models\Configs;
|
|
use App\Models\Live\LiveBanner;
|
|
use App\Models\MerchantShop;
|
|
use App\Models\Server\MerchantInformation;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
class NewMerchantDefaultService implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
protected $merchant_id;
|
|
protected $anchor_id;
|
|
public $tries = 1;
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($data)
|
|
{
|
|
$this->merchant_id = $data['merchant_id'];
|
|
$this->anchor_id = $data['anchor_id'];
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle()
|
|
{
|
|
$this->insertShop($this->merchant_id);
|
|
$this->insertActivity($this->merchant_id,$this->anchor_id);
|
|
$this->insertInformation($this->merchant_id);
|
|
}
|
|
|
|
private function insertShop($merchant_id){
|
|
if($merchant_id == 599) return;
|
|
// $shops = Configs::whereIn('id',[11,12])->pluck('value')->toArray();
|
|
$shop = Configs::where('key','merchantDefaultShop')->first();
|
|
$result = json_decode($shop->value);
|
|
foreach ($result as $key => $value) {
|
|
// $value=json_decode($value);
|
|
MerchantShop::create([
|
|
'merchant_id'=>$merchant_id,
|
|
'title'=>$value->title,
|
|
'sub_title'=>$value->sub_title,
|
|
'icon'=>$value->icon,
|
|
'pay_type'=>$value->pay_type,
|
|
'price'=>$value->price,
|
|
'sku'=>$value->sku,
|
|
'banners'=>$value->banners,
|
|
'describe'=>$value->describe,
|
|
'is_show'=>$value->is_show,
|
|
'share_qrcode'=>$value->share_qrcode,
|
|
'is_top'=>$value->is_top
|
|
]);
|
|
}
|
|
}
|
|
private function insertActivity($merchant_id,$anchor_id){
|
|
// $activities = Configs::whereIn('id',[13,14])->pluck('value')->toArray();
|
|
$activity = Configs::where('key','merchantDefaultActivity')->first();
|
|
$result = json_decode($activity->value);
|
|
foreach ($result as $key => $value) {
|
|
// $value=json_decode($value);
|
|
$res = CommunityActivity::create([
|
|
'anchor_id'=>$anchor_id,
|
|
'merchant_id'=>$merchant_id,
|
|
'price'=>$value->price,
|
|
'title'=>$value->title,
|
|
'Subtitle'=>$value->Subtitle,
|
|
'pv'=>0,
|
|
'pay_type'=>$value->pay_type,
|
|
'describe'=>$value->describe,
|
|
'sort'=>0,
|
|
'status'=>$value->status,
|
|
'start_time'=>$value->start_time,
|
|
'end_time'=>$value->end_time,
|
|
'apply_deadline'=>$value->apply_deadline,
|
|
'pic'=>$value->pic,
|
|
'type'=>$value->type,
|
|
'sku'=>$value->sku,
|
|
'class'=>$value->class,
|
|
'chat_room_id'=>$value->chat_room_id,
|
|
'top_time'=>$value->top_time,
|
|
'is_top'=>$value->is_top,
|
|
'is_love_show'=>$value->is_love_show,
|
|
'reward_status'=>$value->reward_status,
|
|
]);
|
|
if($res->Subtitle == '教你如何创建和管理你的活动,主要分电脑端和移动端'){
|
|
LiveBanner::create([
|
|
'icon'=>json_encode(['https://images.ufutx.com/202111/25/51645d8eabcf3329d9066fe71fbcdafc.png']),
|
|
'class'=>'community',
|
|
'class_id'=>$res->id
|
|
]);
|
|
}
|
|
if($res->Subtitle == '只需要一分钟上传你的服务信息,就可以快速搭建出属于你的服务型平台'){
|
|
LiveBanner::create([
|
|
'icon'=>json_encode(['https://images.ufutx.com/202111/25/c93b2f61ceaf8f6dbfe8b33364f36054.png']),
|
|
'class'=>'community',
|
|
'class_id'=>$res->id
|
|
]);
|
|
}
|
|
}
|
|
|
|
}
|
|
private function insertInformation($merchant_id){
|
|
// $infors = Configs::whereIn('id',[15])->pluck('value')->toArray();
|
|
$infors = Configs::whereIn('key',['merchantDefaultInformation'])->pluck('value')->toArray();
|
|
$config = Configs::where('key','merchantDefaultAdvertise')->first();
|
|
$result = json_decode($config->value);
|
|
foreach ($infors as $key => $value) {
|
|
$value=json_decode($value);
|
|
$infor = MerchantInformation::create([
|
|
'merchant_id'=>$merchant_id,
|
|
'title'=>$value->title,
|
|
'subTitle'=>$value->subTitle,
|
|
'content'=>$value->content,
|
|
'is_top'=>$value->is_top,
|
|
'type'=>$value->type,
|
|
'pic'=>$value->pic,
|
|
'reward_status'=>$value->reward_status,
|
|
'audio_url'=>$value->audio_url,
|
|
'audio_title'=>$value->audio_title,
|
|
'top_time'=>$value->top_time,
|
|
'is_love_show'=>$value->is_love_show,
|
|
]);
|
|
ConfigAdvertise::create([
|
|
'type'=>'information',
|
|
'type_id'=>$infor->id,
|
|
'pic'=>$result->pic,
|
|
'title'=>$result->title,
|
|
'sub_title'=>$result->sub_title,
|
|
'price'=>$result->price??0.00,
|
|
'links'=>$result->links,
|
|
'choose_type'=>$result->choose_type,
|
|
'choose_type_id'=>$result->choose_type_id,
|
|
'class'=>$result->class,
|
|
]);
|
|
}
|
|
}
|
|
}
|