Commit 159ebcd6 159ebcd6f3150ea170d337b098e1e1badb15a1f8 by lemon

修改中间件

1 parent fe2b4516
...@@ -24,7 +24,6 @@ class Kernel extends HttpKernel ...@@ -24,7 +24,6 @@ class Kernel extends HttpKernel
24 \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, 24 \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
25 \App\Http\Middleware\TrimStrings::class, 25 \App\Http\Middleware\TrimStrings::class,
26 \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, 26 \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
27 AuthIdentifier::class
28 ]; 27 ];
29 28
30 /** 29 /**
...@@ -67,5 +66,6 @@ class Kernel extends HttpKernel ...@@ -67,5 +66,6 @@ class Kernel extends HttpKernel
67 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 66 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
68 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 67 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
69 'check.signature' => \App\Http\Middleware\CheckSignature::class, 68 'check.signature' => \App\Http\Middleware\CheckSignature::class,
69 'auth.identifier'=> AuthIdentifier::class,
70 ]; 70 ];
71 } 71 }
......
...@@ -19,9 +19,11 @@ use Illuminate\Support\Facades\Log; ...@@ -19,9 +19,11 @@ use Illuminate\Support\Facades\Log;
19 */ 19 */
20 class AuthIdentifier 20 class AuthIdentifier
21 { 21 {
22 protected $auth = [ 22 /**
23 'api' 23 * @var string[]
24 ]; 24 */
25 protected $auth = ['api'];
26
25 27
26 /** 28 /**
27 * Handle an incoming request. 29 * Handle an incoming request.
...@@ -59,10 +61,8 @@ class AuthIdentifier ...@@ -59,10 +61,8 @@ class AuthIdentifier
59 61
60 if (empty($stakeholder_ids)) return Response::error(ErrorCode::MATCH_IDENTIFIER_FAIL); 62 if (empty($stakeholder_ids)) return Response::error(ErrorCode::MATCH_IDENTIFIER_FAIL);
61 63
62 $request->attributes->add([ 64 $request->offsetSet('identifier', $identifier);
63 'identifier' => $identifier, 65 $request->offsetSet('stakeholder_ids', $stakeholder_ids);
64 'stakeholder_ids' => $stakeholder_ids,
65 ]);
66 66
67 AUTH: 67 AUTH:
68 68
......
...@@ -58,11 +58,11 @@ class BaseModel extends Model ...@@ -58,11 +58,11 @@ class BaseModel extends Model
58 return $builder; 58 return $builder;
59 } 59 }
60 60
61
62
63 /** 61 /**
64 * @param Builder $builder 62 * @param Builder $builder
65 * @return Builder 63 * @return Builder
64 * @throws \Psr\Container\ContainerExceptionInterface
65 * @throws \Psr\Container\NotFoundExceptionInterface
66 */ 66 */
67 public function scopeIdentify(Builder $builder) 67 public function scopeIdentify(Builder $builder)
68 { 68 {
......
...@@ -14,6 +14,8 @@ class Project extends BaseModel ...@@ -14,6 +14,8 @@ class Project extends BaseModel
14 { 14 {
15 use HasFactory,SoftDeletes; 15 use HasFactory,SoftDeletes;
16 16
17 17 /**
18 * @var string[]
19 */
18 public $hidden = ['id']; 20 public $hidden = ['id'];
19 } 21 }
......
...@@ -42,6 +42,7 @@ class RouteServiceProvider extends ServiceProvider ...@@ -42,6 +42,7 @@ class RouteServiceProvider extends ServiceProvider
42 //音乐人 42 //音乐人
43 Route::prefix('api') 43 Route::prefix('api')
44 ->middleware('api') 44 ->middleware('api')
45 ->middleware('auth.identifier')
45 ->namespace($this->namespace . '\Musician') 46 ->namespace($this->namespace . '\Musician')
46 ->group(base_path('routes/api.php')); 47 ->group(base_path('routes/api.php'));
47 48
......
...@@ -32,9 +32,9 @@ class IssueService extends Service ...@@ -32,9 +32,9 @@ class IssueService extends Service
32 32
33 $params['data'] = $this->request->all(); 33 $params['data'] = $this->request->all();
34 $params['ext'] = [ 34 $params['ext'] = [
35 'user_id' => $this->identifier->company_id, //机构id 35 'user_id' => $this->request->get('identifier')->company_id, //机构id
36 'operator' => $this->identifier->user_id, //操作人id 36 'operator' => $this->request->get('identifier')->user_id, //操作人id
37 'stakeholder_ids' => $this->stakeholder_ids, 37 'stakeholder_ids' => $this->request->get('stakeholder_ids'),
38 ]; 38 ];
39 39
40 Log::info(__METHOD__.':请求参数', ['params'=>$params, 'token'=>$token, 'uri'=>$client->post($this->request->getRequestUri())]); 40 Log::info(__METHOD__.':请求参数', ['params'=>$params, 'token'=>$token, 'uri'=>$client->post($this->request->getRequestUri())]);
...@@ -62,7 +62,7 @@ class IssueService extends Service ...@@ -62,7 +62,7 @@ class IssueService extends Service
62 */ 62 */
63 public function subCompany() 63 public function subCompany()
64 { 64 {
65 $company_ids = Stakeholder::query()->whereIn('id', $this->stakeholder_ids)->pluck('company_id')->toArray(); 65 $company_ids = Stakeholder::query()->whereIn('id', $this->request->get('stakeholder_ids'))->pluck('company_id')->toArray();
66 $subject = Subject::query()->whereIn('company_id', $company_ids) 66 $subject = Subject::query()->whereIn('company_id', $company_ids)
67 ->where('attr', 'like', "%3%") 67 ->where('attr', 'like', "%3%")
68 ->groupBy('no') 68 ->groupBy('no')
......
...@@ -20,7 +20,7 @@ class MusicianAgreementService extends Service ...@@ -20,7 +20,7 @@ class MusicianAgreementService extends Service
20 */ 20 */
21 public function treatyList() 21 public function treatyList()
22 { 22 {
23 $res = Contract::query()->whereIn('stakeholder_id', $this->stakeholder_ids)->where('flag', 3)->where('date_ending', '>', $this->now)->with(['filesNewTreaty:id,key,link_id']) 23 $res = Contract::query()->whereIn('stakeholder_id', $this->request->get('stakeholder_ids'))->where('flag', 3)->where('date_ending', '>', $this->now)->with(['filesNewTreaty:id,key,link_id'])
24 ->select(['id', 'name as treaty_name', 'treaty_type', 'service_types as service_type', 'date_ending as deadline_date', 'music_nums as music_no'])->orderByDesc('created_at')->paginate($this->pageSize); 24 ->select(['id', 'name as treaty_name', 'treaty_type', 'service_types as service_type', 'date_ending as deadline_date', 'music_nums as music_no'])->orderByDesc('created_at')->paginate($this->pageSize);
25 25
26 $client = new CosHelper(); 26 $client = new CosHelper();
...@@ -58,7 +58,7 @@ class MusicianAgreementService extends Service ...@@ -58,7 +58,7 @@ class MusicianAgreementService extends Service
58 58
59 //歌曲版权 59 //歌曲版权
60 $contract_table = Contract::table(); 60 $contract_table = Contract::table();
61 $contract = Contract::query()->with(['filesNew:id,key,link_id', 'moreSongs'])->where(['flag'=>1])->whereIn('sc.stakeholder_id', $this->stakeholder_ids) 61 $contract = Contract::query()->with(['filesNew:id,key,link_id', 'moreSongs'])->where(['flag'=>1])->whereIn('sc.stakeholder_id', $this->request->get('stakeholder_ids'))
62 ->join(StakeholderContract::table()." as sc", Contract::table().".id", '=', 'sc.contract_id') 62 ->join(StakeholderContract::table()." as sc", Contract::table().".id", '=', 'sc.contract_id')
63 ->select(["{$contract_table}.id", 'contract_no', 'name', 'right_type', 'proportion', 'date_signing', 'date_starting', 'date_ending', 'cooperation_type', 'prepaid_money', 'reward_money'])->get()->toArray(); 63 ->select(["{$contract_table}.id", 'contract_no', 'name', 'right_type', 'proportion', 'date_signing', 'date_starting', 'date_ending', 'cooperation_type', 'prepaid_money', 'reward_money'])->get()->toArray();
64 64
......
...@@ -46,7 +46,7 @@ class MusicianBalanceService extends Service ...@@ -46,7 +46,7 @@ class MusicianBalanceService extends Service
46 $payer = StakeholderBalanceByPayer::query()->identify()->get(); 46 $payer = StakeholderBalanceByPayer::query()->identify()->get();
47 foreach ($payer as $item) { 47 foreach ($payer as $item) {
48 //计算个人所得税 48 //计算个人所得税
49 $tax = ($this->identifier->type == 1) ? (string)$this->reckonPersonTax($item['balance']) : (string)0; 49 $tax = ($this->request->get('identifier')->type == 1) ? (string)$this->reckonPersonTax($item['balance']) : (string)0;
50 //税后余额 50 //税后余额
51 $balance = bcsub($item['balance'], $tax, Service::DECIMAL); 51 $balance = bcsub($item['balance'], $tax, Service::DECIMAL);
52 52
...@@ -75,7 +75,7 @@ class MusicianBalanceService extends Service ...@@ -75,7 +75,7 @@ class MusicianBalanceService extends Service
75 75
76 foreach ($payer as $item) { 76 foreach ($payer as $item) {
77 77
78 $tax = ($this->identifier->type == 1) ? (string)$this->reckonPersonTax($item->balance) : (string)0; 78 $tax = ($this->request->get('identifier')->type == 1) ? (string)$this->reckonPersonTax($item->balance) : (string)0;
79 //税后余额 79 //税后余额
80 $amount = (string)bcsub($item->balance, $tax, Service::DECIMAL); 80 $amount = (string)bcsub($item->balance, $tax, Service::DECIMAL);
81 81
......
...@@ -40,7 +40,7 @@ class MusicianSongService extends Service ...@@ -40,7 +40,7 @@ class MusicianSongService extends Service
40 foreach ($clause_res as $clause_res_item) { 40 foreach ($clause_res as $clause_res_item) {
41 if($clause = json_decode($clause_res_item)) { 41 if($clause = json_decode($clause_res_item)) {
42 foreach ($clause as $clause_item) { 42 foreach ($clause as $clause_item) {
43 if (in_array($clause_item->stakeholder_id, $this->stakeholder_ids)) { 43 if (in_array($clause_item->stakeholder_id, $this->request->get('stakeholder_ids'))) {
44 $role = array_merge($role, Contract::transformRole($clause_item->right_type)); 44 $role = array_merge($role, Contract::transformRole($clause_item->right_type));
45 } 45 }
46 } 46 }
...@@ -143,7 +143,7 @@ class MusicianSongService extends Service ...@@ -143,7 +143,7 @@ class MusicianSongService extends Service
143 foreach ($clause_res as $clause) { 143 foreach ($clause_res as $clause) {
144 if ($clause = json_decode($clause)){ 144 if ($clause = json_decode($clause)){
145 foreach ($clause as $clause_item) { 145 foreach ($clause as $clause_item) {
146 if (in_array($clause_item->stakeholder_id, $this->stakeholder_ids)) { 146 if (in_array($clause_item->stakeholder_id, $this->request->get('stakeholder_ids'))) {
147 $role = array_merge($role, Contract::transformRole($clause_item->right_type)); 147 $role = array_merge($role, Contract::transformRole($clause_item->right_type));
148 } 148 }
149 } 149 }
...@@ -227,7 +227,7 @@ class MusicianSongService extends Service ...@@ -227,7 +227,7 @@ class MusicianSongService extends Service
227 $right = $role = $rights = []; 227 $right = $role = $rights = [];
228 if (!empty($item['contract']['stakeholder_contract'])) { 228 if (!empty($item['contract']['stakeholder_contract'])) {
229 foreach ($item['contract']['stakeholder_contract'] as $stakeholder_contract) { 229 foreach ($item['contract']['stakeholder_contract'] as $stakeholder_contract) {
230 if (in_array($stakeholder_contract['stakeholder_id'], $this->stakeholder_ids)) { 230 if (in_array($stakeholder_contract['stakeholder_id'], $this->request->get('stakeholder_ids'))) {
231 $right[] = $stakeholder_contract; 231 $right[] = $stakeholder_contract;
232 $role = array_merge($role, Contract::transformRole($stakeholder_contract['right_type'])); 232 $role = array_merge($role, Contract::transformRole($stakeholder_contract['right_type']));
233 233
......
...@@ -85,7 +85,7 @@ class MusicianWithdrawService extends Service ...@@ -85,7 +85,7 @@ class MusicianWithdrawService extends Service
85 { 85 {
86 if (RedisClient::instance('bills')->set(CacheKeyTools::billsConfirm($this->request->serial_no), true, 'EX', 3, 'NX')) { 86 if (RedisClient::instance('bills')->set(CacheKeyTools::billsConfirm($this->request->serial_no), true, 'EX', 3, 'NX')) {
87 87
88 $app = StakeholderIncomeSyncApp::query()->where(['serial_no'=>$this->request->serial_no, 'sync_status'=>1, 'withdraw_status'=>0, 'identifier'=>$this->identifier->identifier, 'type'=>1])->select(['id', 'subject_no', 'company_id', 'stakeholder_id', 'related_id'])->first(); 88 $app = StakeholderIncomeSyncApp::query()->where(['serial_no'=>$this->request->serial_no, 'sync_status'=>1, 'withdraw_status'=>0, 'identifier'=>$this->request->get('identifier')->identifier, 'type'=>1])->select(['id', 'subject_no', 'company_id', 'stakeholder_id', 'related_id'])->first();
89 89
90 DB::beginTransaction(); 90 DB::beginTransaction();
91 91
...@@ -148,7 +148,7 @@ class MusicianWithdrawService extends Service ...@@ -148,7 +148,7 @@ class MusicianWithdrawService extends Service
148 { 148 {
149 if (!$app = StakeholderIncomeSyncApp::query()->where([ 149 if (!$app = StakeholderIncomeSyncApp::query()->where([
150 'serial_no'=>$this->request->serial_no, 150 'serial_no'=>$this->request->serial_no,
151 'identifier'=>$this->identifier->identifier, 151 'identifier'=>$this->request->get('identifier')->identifier,
152 'sync_status'=>1, 152 'sync_status'=>1,
153 ]) 153 ])
154 ->first()) { 154 ->first()) {
......
...@@ -28,7 +28,13 @@ class PropertyTrackService extends Service ...@@ -28,7 +28,13 @@ class PropertyTrackService extends Service
28 */ 28 */
29 public function list() 29 public function list()
30 { 30 {
31 $res = PropertyTrack::query()->where(['create_admin'=>$this->identifier->company_id, 'from'=>1]) 31 print_r($this->request->get('identifier'));
32 exit();
33
34 print_r(\request()->get('identifier'));
35 exit();
36
37 $res = PropertyTrack::query()->where(['create_admin'=>$this->request->get('identifier')->company_id, 'from'=>1])
32 ->when(filled($this->request->input('upload_time')), function (Builder $builder){ 38 ->when(filled($this->request->input('upload_time')), function (Builder $builder){
33 list($start, $end) = explode(' - ', $this->request->input('upload_time')); 39 list($start, $end) = explode(' - ', $this->request->input('upload_time'));
34 $builder->whereBetween('upload_time', [trim($start), trim($end)]); 40 $builder->whereBetween('upload_time', [trim($start), trim($end)]);
...@@ -46,6 +52,7 @@ class PropertyTrackService extends Service ...@@ -46,6 +52,7 @@ class PropertyTrackService extends Service
46 */ 52 */
47 public function show() 53 public function show()
48 { 54 {
55
49 $data = []; 56 $data = [];
50 57
51 //详情 58 //详情
...@@ -64,7 +71,7 @@ class PropertyTrackService extends Service ...@@ -64,7 +71,7 @@ class PropertyTrackService extends Service
64 */ 71 */
65 public function pending() 72 public function pending()
66 { 73 {
67 $count = PropertyTrack::query()->where(['create_admin'=>$this->identifier->company_id])->whereNull('upload_time')->count(); 74 $count = PropertyTrack::query()->where(['create_admin'=>$this->request->get('identifier')->company_id])->whereNull('upload_time')->count();
68 return Response::success(['count'=>$count]); 75 return Response::success(['count'=>$count]);
69 } 76 }
70 77
......
...@@ -53,8 +53,6 @@ class Service ...@@ -53,8 +53,6 @@ class Service
53 public function __construct(Request $request) 53 public function __construct(Request $request)
54 { 54 {
55 $this->request = $request; 55 $this->request = $request;
56 $this->identifier = $request->get('identifier');
57 $this->stakeholder_ids = $request->get('stakeholder_ids');
58 $this->page = (int)$request->input('page', 1); 56 $this->page = (int)$request->input('page', 1);
59 $this->pageSize = (int)$request->input('pageSize', 10); 57 $this->pageSize = (int)$request->input('pageSize', 10);
60 $this->now = Carbon::now()->toDateTimeString(); 58 $this->now = Carbon::now()->toDateTimeString();
......
...@@ -30,7 +30,7 @@ class WithdrawService extends Service implements WithdrawInterface ...@@ -30,7 +30,7 @@ class WithdrawService extends Service implements WithdrawInterface
30 try { 30 try {
31 31
32 //修改状态-》提现中 32 //修改状态-》提现中
33 StakeholderIncomeSyncApp::query()->where(['serial_no'=>$app->serial_no, 'identifier'=>$this->identifier->identifier, 'sync_status'=>1, 'withdraw_status'=>1])->update([ 33 StakeholderIncomeSyncApp::query()->where(['serial_no'=>$app->serial_no, 'identifier'=>$this->request->get('identifier')->identifier, 'sync_status'=>1, 'withdraw_status'=>1])->update([
34 'withdraw_status'=>2 34 'withdraw_status'=>2
35 ]); 35 ]);
36 36
...@@ -43,7 +43,7 @@ class WithdrawService extends Service implements WithdrawInterface ...@@ -43,7 +43,7 @@ class WithdrawService extends Service implements WithdrawInterface
43 //提现申请日志 43 //提现申请日志
44 StakeholderWithdrawAppLogs::query()->create([ 44 StakeholderWithdrawAppLogs::query()->create([
45 'serial_no' => $app->serial_no, 45 'serial_no' => $app->serial_no,
46 'identifier' => $this->identifier->identifier, 46 'identifier' => $this->request->get('identifier')->identifier,
47 'type' => __FUNCTION__, 47 'type' => __FUNCTION__,
48 'withdraw_money' => $app->total_money, 48 'withdraw_money' => $app->total_money,
49 ]); 49 ]);
...@@ -72,7 +72,7 @@ class WithdrawService extends Service implements WithdrawInterface ...@@ -72,7 +72,7 @@ class WithdrawService extends Service implements WithdrawInterface
72 try { 72 try {
73 73
74 //修改状态-》提现中 -> 提现完成 74 //修改状态-》提现中 -> 提现完成
75 StakeholderIncomeSyncApp::query()->where(['serial_no'=>$app->serial_no, 'identifier'=>$this->identifier->identifier, 'sync_status'=>1, 'withdraw_status'=>2])->update([ 75 StakeholderIncomeSyncApp::query()->where(['serial_no'=>$app->serial_no, 'identifier'=>$this->request->get('identifier')->identifier, 'sync_status'=>1, 'withdraw_status'=>2])->update([
76 'withdraw_status'=>3 76 'withdraw_status'=>3
77 ]); 77 ]);
78 78
...@@ -85,7 +85,7 @@ class WithdrawService extends Service implements WithdrawInterface ...@@ -85,7 +85,7 @@ class WithdrawService extends Service implements WithdrawInterface
85 //提现申请日志 85 //提现申请日志
86 StakeholderWithdrawAppLogs::query()->create([ 86 StakeholderWithdrawAppLogs::query()->create([
87 'serial_no' => $app->serial_no, 87 'serial_no' => $app->serial_no,
88 'identifier' => $this->identifier->identifier, 88 'identifier' => $this->request->get('identifier')->identifier,
89 'type' => __FUNCTION__, 89 'type' => __FUNCTION__,
90 'withdraw_money' => $app->total_money, 90 'withdraw_money' => $app->total_money,
91 ]); 91 ]);
...@@ -115,7 +115,7 @@ class WithdrawService extends Service implements WithdrawInterface ...@@ -115,7 +115,7 @@ class WithdrawService extends Service implements WithdrawInterface
115 try { 115 try {
116 116
117 //修改状态-》提现中 -》 已确认 117 //修改状态-》提现中 -》 已确认
118 StakeholderIncomeSyncApp::query()->where(['serial_no'=>$app->serial_no, 'identifier'=>$this->identifier->identifier, 'sync_status'=>1, 'withdraw_status'=>2])->update([ 118 StakeholderIncomeSyncApp::query()->where(['serial_no'=>$app->serial_no, 'identifier'=>$this->request->get('identifier')->identifier, 'sync_status'=>1, 'withdraw_status'=>2])->update([
119 'withdraw_status'=>1 119 'withdraw_status'=>1
120 ]); 120 ]);
121 121
...@@ -128,7 +128,7 @@ class WithdrawService extends Service implements WithdrawInterface ...@@ -128,7 +128,7 @@ class WithdrawService extends Service implements WithdrawInterface
128 //提现申请日志 128 //提现申请日志
129 StakeholderWithdrawAppLogs::query()->create([ 129 StakeholderWithdrawAppLogs::query()->create([
130 'serial_no' => $app->serial_no, 130 'serial_no' => $app->serial_no,
131 'identifier' => $this->identifier->identifier, 131 'identifier' => $this->request->get('identifier')->identifier,
132 'type' => __FUNCTION__, 132 'type' => __FUNCTION__,
133 'withdraw_money' => $app->total_money, 133 'withdraw_money' => $app->total_money,
134 ]); 134 ]);
......
...@@ -57,7 +57,7 @@ Route::group(["prefix"=>"issue"], function (){ ...@@ -57,7 +57,7 @@ Route::group(["prefix"=>"issue"], function (){
57 }); 57 });
58 58
59 //资产 59 //资产
60 Route::group(["prefix"=>"property"], function (){ 60 Route::group(["prefix"=>"property"], function (){
61 Route::get('/track/list', 'PropertyTrackController@list'); 61 Route::get('/track/list', 'PropertyTrackController@list');
62 Route::get('/track/show', 'PropertyTrackController@show'); 62 Route::get('/track/show', 'PropertyTrackController@show');
63 Route::get('/track/pending', 'PropertyTrackController@pending'); 63 Route::get('/track/pending', 'PropertyTrackController@pending');
......