|
@@ -8,6 +8,7 @@
|
|
namespace App\Repositories;
|
|
namespace App\Repositories;
|
|
|
|
|
|
use App\Models\Meta;
|
|
use App\Models\Meta;
|
|
|
|
+use App\Models\Serialize;
|
|
use Dingo\Api\Http\Response;
|
|
use Dingo\Api\Http\Response;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
@@ -31,7 +32,8 @@ class MetaRepository {
|
|
}
|
|
}
|
|
//详情
|
|
//详情
|
|
public function view($request){
|
|
public function view($request){
|
|
- return $this->meta->where([['id','=',$request['patch_num']],['status','=',1]])->first();
|
|
|
|
|
|
+ $info = Serialize::where('serialize',$request['patch_num'])->first();
|
|
|
|
+ return $this->meta->where([['id','=',$info['meta_id']],['status','=',1]])->first();
|
|
}
|
|
}
|
|
//创建
|
|
//创建
|
|
public function create($request){
|
|
public function create($request){
|
|
@@ -66,9 +68,20 @@ class MetaRepository {
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
try{
|
|
try{
|
|
$meta = $this->meta->create($data);
|
|
$meta = $this->meta->create($data);
|
|
-
|
|
|
|
|
|
+ $info = Serialize::where('meta_id',0)->orderBy('id','asc')->first();
|
|
|
|
+ if(empty($info)){
|
|
|
|
+ DB::rollBack();
|
|
|
|
+ return Response::create([
|
|
|
|
+ 'message' => '新增元数据失败,请重试',
|
|
|
|
+ 'error' => '序列号已使用完成,请继续生成',
|
|
|
|
+ 'status_code' => 500
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+ $info->meta_id = $meta->id;
|
|
|
|
+ $info->save();
|
|
DB::commit();
|
|
DB::commit();
|
|
- Storage::put('chsy/qrcodes/'.$meta['patch_num'].'.png',QrCode::size(200)->generate("http://uptoyo.com/".$meta['id']));
|
|
|
|
|
|
+
|
|
|
|
+ Storage::put('chsy/qrcodes/'.$meta['patch_num'].'.png',QrCode::size(200)->generate("http://uptoyo.com/".$info['serialize']));
|
|
return Response::create();
|
|
return Response::create();
|
|
}catch (QueryException $exception){
|
|
}catch (QueryException $exception){
|
|
DB::rollBack();
|
|
DB::rollBack();
|