<?php
/*
 本代码由 口号帮 创建
 创建时间 2019-05-08 16:22:09
 技术支持 口号帮 
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace App\Http\Controllers\Admin;use App\Http\Controllers\BaseController;use App\Models\Product;use App\Models\ProductBatchPrice;use App\Models\ProductType;use Illuminate\Http\Request;use App\Http\Controllers\Controller;class ProductBatchController extends BaseController{public function index(){$type=ProductType::all();return view('admin.product.batch.index',compact('type'));}public function create($type){return view('admin.product.set_price',compact('type'));}public function data(Request $request){$pageSize=$request->input('limit',$this->pageSize);$res=ProductBatchPrice::with(['user'=>function($query){$query->select('id','name');}])->orderBy('id','desc')->paginate($pageSize)->toArray();$P2gAC0=array();$P2gAC0['code']=0;$P2gAC0['msg']='正在请求中...';$P2gAC0['count']=$res['total'];$P2gAC0['data']=$res['data'];$data=$P2gAC0;return response()->json($data);}public function store(Request $request){if(in_array($request->type,['article','zimeiti','video','weixin','weibo','redbook']))goto P2gBodyx2;goto P2gNextx2;P2gBodyx2:$data=$request->except(['_token','data','type']);$select=$request->data;$type=$request->type;$P2gAC0=array();$ids=$P2gAC0;$P2gAC0=array();$success=$P2gAC0;foreach($select as $key=>$val){$AAA_A__="explode";$P2gAC1=$AAA_A__(',',$val);$P2g0=list($k,$v)=$P2gAC1;$ids[]=$v;$P2g0=$v;}$data['ids']=json_encode($ids);$AAA_A_A="count";$P2gAC0=$AAA_A_A($ids);$data['set_number']=$P2gAC0;$data['success_number']=0;$data['uid']=auth()->user()->id;$data['product_type']=$type;$data['success_ids']='';if($data['rate_value'])goto P2gBodyx4;goto P2gNextx4;P2gBodyx4:$P2g0=$data['rate_value']/100;$P2g1=$P2g0;goto P2gx3;P2gNextx4:$P2g1=0;P2gx3:$data['rate_value']=$P2g1;$P2g0=$data['price_value']??0;$data['price_value']=$P2g0;$create=ProductBatchPrice::create($data);set_time_limit(0);$P2g0=$type=='article';if($P2g0)goto P2gBodyx6;goto P2gNextx6;P2gBodyx6:foreach($ids as $item){}goto P2gx5;P2gNextx6:$P2g0=$type=='zimeiti';if($P2g0)goto P2gBodyx7;goto P2gNextx7;P2gBodyx7:foreach($ids as $item){}goto P2gx5;P2gNextx7:$P2g0=$type=='weixin';if($P2g0)goto P2gBodyx8;goto P2gNextx8;P2gBodyx8:foreach($ids as $item){}goto P2gx5;P2gNextx8:$P2g0=$type=='weibo';if($P2g0)goto P2gBodyx9;goto P2gNextx9;P2gBodyx9:foreach($ids as $item){}goto P2gx5;P2gNextx9:$P2g0=$type=='video';if($P2g0)goto P2gBodyxa;goto P2gNextxa;P2gBodyxa:goto P2gx5;P2gNextxa:P2gx5:$create->success_ids=json_encode($success);$AAA_AA_="count";$P2gAC0=$AAA_AA_($success);$create->success_number=$P2gAC0;$create->status=1;$create->save();goto P2gx1;P2gNextx2:$this->set('type',$this->badRequest);$this->set('info','资源类型错误');P2gx1:return $this->jsonResponse();}}
?>