MusicianWithdrawService.php
3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
namespace App\Services;
use App\Helper\ErrorCode;
use App\Helper\Response;
use App\Models\Legal\Company;
use App\Models\Legal\Contract;
use App\Models\Legal\StakeholderIncomeByPayer;
use App\Models\Legal\StakeholderIncomeSyncAppDetails;
use App\Models\Legal\StakeholderSongCollate;
/**
* Class MusicianAgreementService
* @package App\Services
*/
class MusicianWithdrawService extends Service
{
/**
* 返回账单详情
* @return \Illuminate\Http\JsonResponse
*/
public function walletDetail()
{
$income_by_payer = StakeholderIncomeSyncAppDetails::query()->where(['serial_no'=>$this->request->input('busi_id'), 'sync_status'=>1])->first();
if (empty($income_by_payer)) return Response::error(ErrorCode::ORDER_NO_FOUND);
$collate = StakeholderSongCollate::query()->with('song:id,name,singer')->where([
'bills_id'=>$income_by_payer->related_id, 'subject_no'=>$income_by_payer->subject_no])
->select(['song_id', 'role', 'cost_amount', 'deduct_amount', 'real_share_amount'])->paginate($this->pageSize);
foreach ($collate as &$item) {
$item->setAttribute('role', Contract::transformRole($item->role));
}
return Response::success($collate);
}
/**
* 发票信息 - 通过名字
* @return \Illuminate\Http\JsonResponse|mixed
*/
public function receiptInfoByName()
{
if ($receipt = Company::query()->where(['receipt_name'=>$this->request->input('name')])->first()) {
return Response::success([
'receipt_type' => $receipt->receipt_type,
'receipt_name' => $receipt->receipt_name,
'receipt_no' => $receipt->receipt_no,
'receipt_tel' => $receipt->receipt_tel,
'receipt_address' => $receipt->receipt_address,
'receipt_bank' => $receipt->receipt_bank,
'receipt_bank_no' => $receipt->receipt_bank_no,
'receipt_consignee' => $receipt->post_consignee, //收件人
'post_address' => $receipt->post_address, //邮寄地址
'post_phone' => $receipt->post_phone, //邮寄电话
]);
} else {
return Response::error();
}
}
/**
* 修改提现状态
* @return \Illuminate\Http\JsonResponse|mixed
*/
public function changeStatus()
{
$withdraw_status = '';
$query = StakeholderIncomeSyncAppDetails::query()->where(['sync_status'=>1, 'identifier'=>$this->identifier->identifier])
->whereIn('serial_no', $this->request->input('busi_id'));
switch ($this->request->input('type')) {
case 'confirm': //已确认
$withdraw_status = 1;
$query = $query->where(['withdraw_status'=>0]);
break;
case 'fail': //提现失败 -> 待提现
$withdraw_status = 1;
$query = $query->where(['withdraw_status'=>2]);
break;
case 'advance': //提现中
$withdraw_status = 2;
$query = $query->where(['withdraw_status'=>1]);
break;
case 'success': //提现完成
$withdraw_status = 3;
$query = $query->where(['withdraw_status'=>2]);
break;
}
if ($query->update(['withdraw_status'=>$withdraw_status])) {
return Response::success();
} else {
return Response::error();
}
}
}