533 lines
22 KiB
PHP
533 lines
22 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
namespace App\Http\Controllers\Admin;
|
|||
|
|
|
|||
|
|
use App\Common\cache\redis\ApiRedisKey;
|
|||
|
|
use App\Models\MpAdvertises;
|
|||
|
|
use Illuminate\Http\Request;
|
|||
|
|
use App\Http\Controllers\Controller;
|
|||
|
|
use App\Models\Course\Course;
|
|||
|
|
use App\Services\IMService;
|
|||
|
|
use App\Models\HandleLogs;
|
|||
|
|
use App\Models\Live\Anchor;
|
|||
|
|
use App\Repositories\Eloquent\SmsRepository as Sms;
|
|||
|
|
use App\Contracts\UserContract;
|
|||
|
|
use App\Models\MerchantAccount;
|
|||
|
|
use EasyWeChat\Factory;
|
|||
|
|
use App\Models\CommunityActivity;
|
|||
|
|
use App\Models\Configs;
|
|||
|
|
use App\Models\Earning;
|
|||
|
|
use App\Models\EarningWithdraw;
|
|||
|
|
use App\Models\MerchantInformation;
|
|||
|
|
use App\Models\TouristOrder;
|
|||
|
|
use App\Models\WangYiYunUser;
|
|||
|
|
use App\Models\MEarning;
|
|||
|
|
use App\Models\MEarningwithdraws;
|
|||
|
|
use App\Models\MerchantShop;
|
|||
|
|
use App\Models\MerchantUsers;
|
|||
|
|
use App\Models\Server\MerchantShareChannel;
|
|||
|
|
use App\Models\Server\MerchantUser;
|
|||
|
|
use App\Models\ShopRecive;
|
|||
|
|
use App\Models\User;
|
|||
|
|
use App\Models\WebsiteUser;
|
|||
|
|
use Illuminate\Support\Facades\Log;
|
|||
|
|
use Illuminate\Support\Facades\Redis;
|
|||
|
|
|
|||
|
|
use function AlibabaCloud\Client\json;
|
|||
|
|
|
|||
|
|
class PlatformController extends Controller
|
|||
|
|
{
|
|||
|
|
protected $sms;
|
|||
|
|
protected $userCon;
|
|||
|
|
protected $viewer;
|
|||
|
|
protected $app;
|
|||
|
|
protected $config;
|
|||
|
|
|
|||
|
|
public function __construct(Sms $sms, UserContract $userCon)
|
|||
|
|
{
|
|||
|
|
$this->config = [
|
|||
|
|
'app_id' => config('wechat.official_account.new.app_id'),
|
|||
|
|
'secret' => config('wechat.official_account.new.secret'),
|
|||
|
|
'token' => config('wechat.official_account.new.token'),
|
|||
|
|
'aes_key' => config('wechat.official_account.new.aes_key')
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
$this->app = Factory::officialAccount($this->config);
|
|||
|
|
$this->sms = $sms;
|
|||
|
|
$this->userCon = $userCon;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 咨询师列表-后台选择
|
|||
|
|
public function platCommunityList(Request $request)
|
|||
|
|
{
|
|||
|
|
$anchor_id = $request->anchor_id;
|
|||
|
|
$activities = CommunityActivity::where('anchor_id',$anchor_id)->where('status',1)->where('type','fullink')->orderBy('sort','desc')->get();
|
|||
|
|
return $this->success('ok',$activities);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public function queryOrders(Request $request){
|
|||
|
|
$trade_no = $request->trade_no;
|
|||
|
|
$result = \WechatService::orderPaid($trade_no);
|
|||
|
|
return $this->success('ok',$result);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//收益记录 打款记录
|
|||
|
|
public function merchantRecordV2(Request $request,$id){
|
|||
|
|
$type = $request->type??'income';
|
|||
|
|
$result = TouristOrder::with('operator');
|
|||
|
|
if($type=='income'){
|
|||
|
|
$result = $result->wherenotin('type',['system']);
|
|||
|
|
}else{
|
|||
|
|
$result = $result->where('type','system');
|
|||
|
|
}
|
|||
|
|
$result = $result->where('merchant_id',$id)
|
|||
|
|
->whereIn('pay_status',[1,4])
|
|||
|
|
->orderBy('id','desc')
|
|||
|
|
->paginate();
|
|||
|
|
foreach ($result as $key => $value) {
|
|||
|
|
$can_withdraw_count = MEarning::where('m_order_id',$value->id)->where('m_id',$id)->where('m_user_id',0)->sum('value')??0;
|
|||
|
|
$value->can_withdraw_count = $value->price;
|
|||
|
|
if($can_withdraw_count>0)
|
|||
|
|
$value->can_withdraw_count = $can_withdraw_count;
|
|||
|
|
if($value->type == 'community'){
|
|||
|
|
$activity = CommunityActivity::withTrashed()->where('id',$value->type_id)->first();
|
|||
|
|
if($activity->class == 'one'){
|
|||
|
|
$goods = CommunityActivity::withTrashed()->where('id',$value->type_id)->where('class','one')->value('title');
|
|||
|
|
$value->goods = '购买了活动《'.$goods."》";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if($value->mobile=='未获取'){
|
|||
|
|
$linkmen = json_decode( $value->linkmen,true);
|
|||
|
|
$value->mobile = !empty($linkmen) ? $linkmen[0]['mobile'] : '未获取';
|
|||
|
|
}
|
|||
|
|
if($value->name=='未获取'){
|
|||
|
|
$linkmen = json_decode( $value->linkmen,true);
|
|||
|
|
$value->name = $linkmen[0]['name'];
|
|||
|
|
}
|
|||
|
|
if($value->type == 'community'){
|
|||
|
|
$service = CommunityActivity::withTrashed()->where('id',$value->type_id)->first();
|
|||
|
|
if($service->class == 'many'){
|
|||
|
|
$goods = CommunityActivity::withTrashed()->where('id',$value->type_id)->where('class','many')->value('title');
|
|||
|
|
$value->goods = '购买了服务《'.$goods."》";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if($value->type == 'course'){
|
|||
|
|
$goods = Course::withTrashed()->where('id',$value->type_id)->value('title');
|
|||
|
|
$value->goods = '购买了课程《'.$goods."》";
|
|||
|
|
}
|
|||
|
|
if($value->type == 'shop'){
|
|||
|
|
$goods = MerchantShop::withTrashed()->where('id',$value->type_id)->value('title');
|
|||
|
|
$addres = ShopRecive::where('order_id',$value->id)->value('address');
|
|||
|
|
$value->goods = '购买了商品《'.$goods."》";
|
|||
|
|
$value->address = $addres;
|
|||
|
|
}
|
|||
|
|
if($value->type == 'system'){
|
|||
|
|
$value->goods = '系统转账';
|
|||
|
|
}
|
|||
|
|
if($value->type == 'reward_info'){
|
|||
|
|
$user = MerchantUsers::where('id',$value->account_id)->first();
|
|||
|
|
$goods = MerchantInformation::withTrashed()->where('id',$value->type_id)->value('title');
|
|||
|
|
$value->goods ='赞赏了资讯《'.$goods."》";
|
|||
|
|
$value->name = $user->nickname??'匿名用户';
|
|||
|
|
$value->mobile = $user->mobile??'';
|
|||
|
|
}
|
|||
|
|
if($value->type == 'reward_activity'){
|
|||
|
|
$user = MerchantUsers::where('id',$value->account_id)->first();
|
|||
|
|
$goods = CommunityActivity::withTrashed()->where('id',$value->type_id)->value('title');
|
|||
|
|
$value->goods ='赞赏了活动《'.$goods."》";
|
|||
|
|
$value->name = $user->nickname??'匿名用户';
|
|||
|
|
$value->mobile = $user->mobile??'';
|
|||
|
|
}
|
|||
|
|
if($value->type == 'transfer'){
|
|||
|
|
$user = Anchor::where('m_id',$value->merchant_id)->first();
|
|||
|
|
$value->goods = '商家'.$user->name.'发起转账'.$value->price.'元';
|
|||
|
|
$value->name = $user->name;
|
|||
|
|
$value->mobile = $user->mobile??'';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return $this->success('ok',$result);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//提现记录
|
|||
|
|
public function cashoutLogsFullink(Request $request,$id){
|
|||
|
|
$type = $request->type ?? 'merchant';
|
|||
|
|
$start_time = $request->start_time;
|
|||
|
|
$end_time = $request->end_time;
|
|||
|
|
if($type == 'merchant'){
|
|||
|
|
$result = MEarningwithdraws::select('id','way','real_value','value','status','created_at')->where('m_id', $id)->where('m_user_id',0)
|
|||
|
|
->orderBy('id','desc');
|
|||
|
|
}elseif($type== 'merchant_user'){
|
|||
|
|
$result = MEarningwithdraws::select('id','way','real_value','value','status','created_at')->where('m_user_id',$id);
|
|||
|
|
}else{
|
|||
|
|
$result = EarningWithdraw::select('id','way','real_value','value','status','created_at')->where('user_id',$id);
|
|||
|
|
}
|
|||
|
|
if($start_time && $end_time){
|
|||
|
|
$result = $result->whereBetween('created_at',[$start_time,$end_time]);
|
|||
|
|
}
|
|||
|
|
$result = $result->orderBy('id','desc')->paginate();
|
|||
|
|
foreach ($result as $key => $value) {
|
|||
|
|
$value->poundage = number_format($value->value-$value->real_value,2)??0;
|
|||
|
|
$value->actual_received = floatval($value->real_value);
|
|||
|
|
$value->amount = floatval($value->value);
|
|||
|
|
$value->type = $value->way;
|
|||
|
|
}
|
|||
|
|
return $this->success('ok',$result);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function userEarnings(Request $request){
|
|||
|
|
try {
|
|||
|
|
$type = $request->type??'merchant_user';
|
|||
|
|
$type_id = $request->type_id;
|
|||
|
|
if($type == 'merchant_user'){
|
|||
|
|
$result = MEarning::where('m_user_id', $type_id)->select('id','m_order_id','type','status','sharer','value','created_at');
|
|||
|
|
}else{
|
|||
|
|
$result = Earning::where('user_id', $type_id)->select('id','order_id','type','status','sharer','value','created_at');;
|
|||
|
|
}
|
|||
|
|
$result = $result->orderBy('id', 'desc')->paginate();;
|
|||
|
|
foreach ($result as $key => $value) {
|
|||
|
|
if($value->order_id){
|
|||
|
|
$value->title = $value->order ? $value->order->goods : '未获取';
|
|||
|
|
$value->nickname = $value->order ? User::where('id',$value->order->user_id)->value('nickname') :'未获取';
|
|||
|
|
$value->mobile = $value->order ? User::where('id',$value->order->user_id)->value('mobile') :'未获取';
|
|||
|
|
}elseif($value->m_order_id){
|
|||
|
|
$value->title = $value->order ? $value->order->desc : '未获取';
|
|||
|
|
if ($value->$type == 'enter') {
|
|||
|
|
$merchant = MerchantAccount::where('id', $value->m_id)->first();
|
|||
|
|
$value->nickname = $merchant->anchorV2->name ?? '';
|
|||
|
|
$value->mobile = $merchant->anchorV2->mobile;
|
|||
|
|
$value->title = '商户' . $value->nickname . '入驻,获取奖励' . $value->value . '元';
|
|||
|
|
}else{
|
|||
|
|
$nickname = $value->order ? $value->order->name : '';
|
|||
|
|
if(empty($nickname) || $nickname == '未获取') $nickname = MerchantUser::where('id',$value->order->account_id)->value('nickname');
|
|||
|
|
$mobile = $value->order ? $value->order->mobile : '';
|
|||
|
|
if(empty($mobile) || $mobile == '未获取') $mobile = MerchantUser::where('id',$value->order->account_id)->value('mobile');
|
|||
|
|
$value->nickname = $nickname;
|
|||
|
|
$value->mobile = $mobile;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// $value->mobile = $value->order ? $value->order->mobile : '未获取';
|
|||
|
|
$time = date('Y-m-d', $value->created_at->timestamp);
|
|||
|
|
if ($value->sharer == 'first_sharer') {
|
|||
|
|
$value->title = '你推荐注册的' . $value->nickname . ',' . $time . ' 购买了【' . $value->title . '】';
|
|||
|
|
} elseif ($value->sharer == 'last_sharer') {
|
|||
|
|
$value->title = $value->nickname . '通过你的直接分享,' . $time . ' 购买了【' . $value->title . '】';
|
|||
|
|
} elseif ($value->sharer == 'other_sharer') {
|
|||
|
|
$value->title = $value->nickname . '通过你的间接分享,' . $time . ' 购买了【' . $value->title . '】';
|
|||
|
|
}
|
|||
|
|
if ($value->sharer == 'channel') {
|
|||
|
|
$channel_id = $value->order->share_channel_id ?? 0;
|
|||
|
|
$title = MerchantShareChannel::where('id', $channel_id)->value('title') ?? '渠道推广';
|
|||
|
|
$value->title = $value->nickname . '通过你的渠道【' . $title . '】购买了【' . $value->title . '】';
|
|||
|
|
}
|
|||
|
|
$value->order_price = $value->order->price ?? 0;
|
|||
|
|
unset($value->order);
|
|||
|
|
}
|
|||
|
|
return $this->success('ok', $result);
|
|||
|
|
}catch (\Exception $e){
|
|||
|
|
$this->getError($e);
|
|||
|
|
return $this->failure('服务器休息中,请稍后再试');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//重置密码
|
|||
|
|
public function sendNoticeToAnchor(Request $request){
|
|||
|
|
$anchor_id = $request->anchor_id;
|
|||
|
|
$anchor = Anchor::find($anchor_id);
|
|||
|
|
if(empty($anchor->mobile)) return $this->failure('该老师尚未绑定电话号码,无法重置');
|
|||
|
|
$mobile = $anchor->mobile;
|
|||
|
|
$openid = $anchor->openid??0;
|
|||
|
|
MerchantAccount::updateOrCreate(['mobile'=>$mobile],['password'=>encrypt($mobile),'openid'=>$openid]);
|
|||
|
|
return $this->success('ok');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//联系我们 合作共赢
|
|||
|
|
public function websiteUser(Request $request){
|
|||
|
|
$name = $request->name;
|
|||
|
|
$contact = $request->contact;
|
|||
|
|
$leave_message = $request->leave_message;
|
|||
|
|
$user = new WebsiteUser();
|
|||
|
|
$user->name = $name;
|
|||
|
|
$user->contact = $contact;
|
|||
|
|
$user->leave_message = $leave_message;
|
|||
|
|
$user->save();
|
|||
|
|
return $this->success('ok');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//联系列表
|
|||
|
|
public function contactList(Request $request){
|
|||
|
|
$keyword = $request->keyword;
|
|||
|
|
$users = WebsiteUser::orderBy('id','desc');
|
|||
|
|
if($keyword){
|
|||
|
|
$keyword = trim($keyword);
|
|||
|
|
$users = $users->where(function($sql) use($keyword){
|
|||
|
|
$sql->where('name','like','%'.$keyword.'%')
|
|||
|
|
->orWhere('contact','like','%'.$keyword.'%');
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
$users = $users->paginate();
|
|||
|
|
foreach ($users as $key => $user) {
|
|||
|
|
if($user->desc) {
|
|||
|
|
$user->desc = json_decode($user->desc);
|
|||
|
|
}else{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return $this->success('ok',$users);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//增加官网用户跟进内容
|
|||
|
|
public function followWebsiteUser(Request $request,$id){
|
|||
|
|
$user = WebsiteUser::find($id);
|
|||
|
|
$descs = $request->descs;
|
|||
|
|
if (empty($descs)) return $this->failure('请按要求填写跟进内容');
|
|||
|
|
if (empty($user->desc)){
|
|||
|
|
$record = array(
|
|||
|
|
array('chat_way'=>$descs[0],'chat_content'=>$descs[1],'chat_result'=>$descs[2]));
|
|||
|
|
}else{
|
|||
|
|
$desc = json_decode($user->desc);
|
|||
|
|
$array = ['chat_way'=>$descs[0],'chat_content'=>$descs[1],'chat_result'=>$descs[2]];
|
|||
|
|
array_push($desc, $array);
|
|||
|
|
$record = $desc;
|
|||
|
|
}
|
|||
|
|
$user->desc = json_encode($record);
|
|||
|
|
$user->save();
|
|||
|
|
return $this->success('ok');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//批量删除
|
|||
|
|
public function removeWebsiteUsers(Request $request){
|
|||
|
|
$ids = $request->ids;
|
|||
|
|
if(!$ids) return $this->failure('请选择要操作的内容');
|
|||
|
|
WebsiteUser::whereIn('id',$ids)->delete();
|
|||
|
|
return $this->success('ok');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//设置手续费
|
|||
|
|
public function configPoundage(Request $request){
|
|||
|
|
$poundage = $request->poundage ?? 1;//百分制
|
|||
|
|
$key = 'withdrawal_poundage';
|
|||
|
|
if($poundage > 100 || $poundage < 0 || !is_numeric($poundage)){
|
|||
|
|
return $this->failure('请输入有效的提现所收取的手续费百分比');
|
|||
|
|
}
|
|||
|
|
Redis::set($key,$poundage);
|
|||
|
|
return $this->success('ok');
|
|||
|
|
}
|
|||
|
|
//获取手续费
|
|||
|
|
public function obtainPoundage(Request $request){
|
|||
|
|
$key = 'withdrawal_poundage';
|
|||
|
|
$poundage = Redis::get($key)??2;
|
|||
|
|
return $this->success('ok',$poundage);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//HTTP请求(支持HTTP/HTTPS,支持GET/POST)
|
|||
|
|
private function http_request($url, $data = null)
|
|||
|
|
{
|
|||
|
|
try{
|
|||
|
|
$curl = curl_init();
|
|||
|
|
curl_setopt($curl, CURLOPT_URL, $url);
|
|||
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
|||
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
|
|||
|
|
if (!empty($data)) {
|
|||
|
|
curl_setopt($curl, CURLOPT_POST, TRUE);
|
|||
|
|
curl_setopt($curl, CURLOPT_POSTFIELDS,$data);
|
|||
|
|
}
|
|||
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
|
|||
|
|
$output = curl_exec($curl);
|
|||
|
|
curl_close($curl);
|
|||
|
|
return json_decode($output,true);
|
|||
|
|
}catch(\Exception $e){
|
|||
|
|
HandleLogs::error('HTTP请求 异常','微信内容安全',$e);
|
|||
|
|
return '';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//添加修改小程序广告位
|
|||
|
|
public function editMpAdevertise(Request $request){
|
|||
|
|
try {
|
|||
|
|
if(empty($request->pic) || !isset($request->pic)) {
|
|||
|
|
return $this->failure('图片必填');
|
|||
|
|
}
|
|||
|
|
if(empty($request->thumbnail) || !isset($request->thumbnail)) {
|
|||
|
|
return $this->failure('缩略图必填');
|
|||
|
|
}
|
|||
|
|
if(empty($request->jump_url) || !isset($request->jump_url)) {
|
|||
|
|
return $this->failure('跳转必填');
|
|||
|
|
}
|
|||
|
|
if(isset($request->id) && $request->id) {
|
|||
|
|
$mp_advertise = MpAdvertises::find($request->id);
|
|||
|
|
if(!$mp_advertise) {
|
|||
|
|
return $this->failure('广告位不存在');
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
$mp_advertise = new MpAdvertises();
|
|||
|
|
}
|
|||
|
|
$mp_advertise->pic = $request->pic;
|
|||
|
|
$mp_advertise->thumbnail = $request->thumbnail;
|
|||
|
|
$mp_advertise->jump_url = $request->jump_url;
|
|||
|
|
if(isset($request->status)) {
|
|||
|
|
$mp_advertise->status = $request->status;
|
|||
|
|
}
|
|||
|
|
$mp_advertise->save();
|
|||
|
|
return $this->success('ok');
|
|||
|
|
} catch (\Exception $e) {
|
|||
|
|
Log::error($e->getMessage());
|
|||
|
|
return $this->failure('数据错误');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获取所有小程序广告位
|
|||
|
|
public function mpAdevertises(Request $request)
|
|||
|
|
{
|
|||
|
|
try {
|
|||
|
|
$advertises = MpAdvertises::orderBy('id','desc')->get();
|
|||
|
|
return $this->success('ok',$advertises);
|
|||
|
|
} catch (\Exception $e) {
|
|||
|
|
Log::error($e->getMessage());
|
|||
|
|
return $this->failure('数据错误');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 删除广告位
|
|||
|
|
public function delMpAdvertise(Request $request,$mp_advertise_id)
|
|||
|
|
{
|
|||
|
|
try {
|
|||
|
|
MpAdvertises::where('id',$mp_advertise_id)->delete();
|
|||
|
|
return $this->success('ok');
|
|||
|
|
} catch (\Exception $e) {
|
|||
|
|
Log::error($e->getMessage());
|
|||
|
|
return $this->failure('数据错误');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 小程序首页弹框配置
|
|||
|
|
public function mpHomePopout(Request $request){
|
|||
|
|
$path = $request->path;
|
|||
|
|
$path_type = $request->path_type;
|
|||
|
|
$pic = $request->pic;
|
|||
|
|
$status = $request->status ?? 1;
|
|||
|
|
$type_id = $request->type_id;
|
|||
|
|
$marriage_pic = $request->marriage_pic;
|
|||
|
|
$area_status = $request->area_status ?? 0;
|
|||
|
|
$province = $request->province ?? '';
|
|||
|
|
$city = $request->city ?? '';
|
|||
|
|
if(empty($path_type) || empty($pic) || empty($type_id)){
|
|||
|
|
return $this->failure('完善表单所有内容才能提交');
|
|||
|
|
}
|
|||
|
|
$com = CommunityActivity::where('id',$type_id)->first();
|
|||
|
|
if(!$com) return $this->failure('输入的id有误 请确认后再保存');
|
|||
|
|
if($com->class == 'one'){
|
|||
|
|
$type = 'activity';
|
|||
|
|
$path = '/pages/party/detail?party_id='.$type_id.'&is_mp_show=1';
|
|||
|
|
}else{
|
|||
|
|
$type = 'service';
|
|||
|
|
$path = '/pages/party/servicesDetail?party_id='.$type_id.'&is_mp_show=1';
|
|||
|
|
}
|
|||
|
|
$array = [
|
|||
|
|
'path'=>$path,
|
|||
|
|
'path_type'=>$path_type,
|
|||
|
|
'pic'=>$pic,
|
|||
|
|
'status'=> $status,
|
|||
|
|
'type'=>$type,
|
|||
|
|
'type_id'=>$type_id,
|
|||
|
|
'marriage_pic'=>$marriage_pic,
|
|||
|
|
'area_status' => $area_status,
|
|||
|
|
'province' => $province,
|
|||
|
|
'city' => $city,
|
|||
|
|
];
|
|||
|
|
Configs::create([
|
|||
|
|
'key' => 'mp_home_popout',
|
|||
|
|
'value' => json_encode($array),
|
|||
|
|
'remark' => '小程序首页弹框',
|
|||
|
|
]);
|
|||
|
|
return $this->success('ok');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//编辑 小程序首页弹框配置
|
|||
|
|
public function updatehomePopout(Request $request){
|
|||
|
|
$id = $request->id;
|
|||
|
|
if(empty($id)){
|
|||
|
|
return $this->failure('id不为空');
|
|||
|
|
}
|
|||
|
|
$config = Configs::where('id',$id)->first();
|
|||
|
|
if($request->has('path_type')){
|
|||
|
|
$array['path_type'] = $request->path_type;
|
|||
|
|
}
|
|||
|
|
if($request->has('pic') ){
|
|||
|
|
$array['pic'] = $request->pic;
|
|||
|
|
}
|
|||
|
|
if($request->has('marriage_pic')){
|
|||
|
|
$array['marriage_pic'] = $request->marriage_pic;
|
|||
|
|
}
|
|||
|
|
if($request->has('status')){
|
|||
|
|
$array['status'] = $request->status;
|
|||
|
|
}
|
|||
|
|
if($request->has('type_id') && $request->type_id){
|
|||
|
|
$array['type_id'] = $request->type_id;
|
|||
|
|
$com = CommunityActivity::where('id',$request->type_id)->first();
|
|||
|
|
if(!$com) return $this->failure('输入的id有误 请确认后再保存');
|
|||
|
|
if($com->class == 'one'){
|
|||
|
|
$type = 'activity';
|
|||
|
|
$path = '/pages/party/detail?party_id='.$request->type_id.'&is_mp_show=1';
|
|||
|
|
}else{
|
|||
|
|
$type = 'service';
|
|||
|
|
$path = '/pages/party/servicesDetail?party_id='.$request->type_id.'&is_mp_show=1';
|
|||
|
|
}
|
|||
|
|
$array['type'] = $type;
|
|||
|
|
$array['path'] = $path;
|
|||
|
|
}else{
|
|||
|
|
$array['type_id'] = 0;
|
|||
|
|
$array['type'] = null;
|
|||
|
|
$array['path'] = '/';
|
|||
|
|
}
|
|||
|
|
//地区限制开关
|
|||
|
|
if($request->has('area_status')){
|
|||
|
|
$array['area_status'] = $request->area_status;
|
|||
|
|
}
|
|||
|
|
//地区 - 省
|
|||
|
|
if($request->has('province')){
|
|||
|
|
$array['province'] = $request->province;
|
|||
|
|
}
|
|||
|
|
//地区 - 市
|
|||
|
|
if($request->has('city')){
|
|||
|
|
$array['city'] = $request->city;
|
|||
|
|
}
|
|||
|
|
$config->value = json_encode($array);
|
|||
|
|
$config->save();
|
|||
|
|
return $this->success('ok');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获取小程序首页弹框配置
|
|||
|
|
public function homePopoutList(Request $request){
|
|||
|
|
$config = Configs::where('key','mp_home_popout')->get();
|
|||
|
|
foreach ($config as $key => $value) {
|
|||
|
|
$value->value = json_decode($value->value);
|
|||
|
|
$cache_key = ApiRedisKey::getHomePopoutClickUserKey($value->id);
|
|||
|
|
$value->click_user_num = Redis::sCard($cache_key) ?: 0;
|
|||
|
|
}
|
|||
|
|
return $this->success('ok',$config);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 删除小程序首页弹窗
|
|||
|
|
* @param Request $request
|
|||
|
|
*/
|
|||
|
|
public function deleteHomePopout(Request $request){
|
|||
|
|
$id = $request->id;
|
|||
|
|
if(empty($id)){
|
|||
|
|
return $this->failure('id不为空');
|
|||
|
|
}
|
|||
|
|
try {
|
|||
|
|
Configs::where('id',$id)->delete();
|
|||
|
|
return $this->success('ok');
|
|||
|
|
} catch (\Exception $e) {
|
|||
|
|
Log::error($e->getMessage());
|
|||
|
|
return $this->failure('数据错误');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|