Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Cong.Zhao
/
musician-api.hikoon.com
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
6957ea96
...
6957ea96f1ba1a3a38c430aa3ee3eac67eb07041
authored
2021-11-17 15:39:44 +0800
by
lemon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提现申请
1 parent
ccf45dbb
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
105 additions
and
18 deletions
app/ApiInterface/WithdrawInterface.php
app/Console/Commands/StakeholderIncomeSyncCommand.php
app/Helper/ErrorCode.php
app/Http/Controllers/Musician/MusicianWithdrawController.php
app/Models/Legal/StakeholderWithdrawAppLogs.php
app/Services/MusicianWithdrawService.php
app/Services/WithdrawService.php
routes/api.php
app/ApiInterface/WithdrawInterface.php
View file @
6957ea9
...
...
@@ -2,15 +2,17 @@
namespace
App\ApiInterface
;
use
App\Models\Legal\StakeholderIncomeSyncApp
;
/**
* Interface PaymentInterface
* @package App\ApiInterface
*/
interface
WithdrawInterface
{
public
function
advance
(
string
$serial_no
);
public
function
advance
(
StakeholderIncomeSyncApp
$app
);
public
function
success
(
string
$serial_no
);
public
function
success
(
StakeholderIncomeSyncApp
$app
);
public
function
fail
(
string
$serial_no
);
public
function
fail
(
StakeholderIncomeSyncApp
$app
);
}
...
...
app/Console/Commands/StakeholderIncomeSyncCommand.php
View file @
6957ea9
...
...
@@ -126,8 +126,6 @@ class StakeholderIncomeSyncCommand extends Command
DB
::
rollBack
();
Log
::
channel
(
'api'
)
->
error
(
__METHOD__
,
[
'msg'
=>
$e
->
getMessage
(),
'request'
=>
$request
,
'response'
=>
$response
]);
}
}
/**
...
...
app/Helper/ErrorCode.php
View file @
6957ea9
...
...
@@ -20,6 +20,8 @@ class ErrorCode
const
WITHDRAW_NO_RECORD
=
40051
;
const
WITHDRAW_HANDLE_ERROR
=
40052
;
const
WITHDRAW_CONFIRM_BILLS_FAIL
=
40053
;
const
WITHDRAW_APPLY_FAIL
=
40054
;
/**
...
...
@@ -39,6 +41,7 @@ class ErrorCode
self
::
WITHDRAW_NO_RECORD
=>
'未匹配有效提现记录'
,
self
::
WITHDRAW_HANDLE_ERROR
=>
'提现操作失败'
,
self
::
WITHDRAW_CONFIRM_BILLS_FAIL
=>
'确认账单失败'
,
self
::
WITHDRAW_APPLY_FAIL
=>
'提现申请失败'
,
];
...
...
app/Http/Controllers/Musician/MusicianWithdrawController.php
View file @
6957ea9
...
...
@@ -8,6 +8,7 @@ use App\Http\Requests\Musician\MusicianWithdrawReceiptByNameRequest;
use
App\Http\Requests\Musician\MusicianWithdrawReceiptRequest
;
use
App\Http\Requests\Musician\MusicianWithdrawStatusRequest
;
use
App\Services\MusicianWithdrawService
;
use
App\Services\WithdrawService
;
/**
* Class MusicianWithdrawController
...
...
@@ -53,8 +54,8 @@ class MusicianWithdrawController extends Controller
* 提现状态修改
* @return \Illuminate\Http\JsonResponse
*/
public
function
withdraw
(
MusicianWithdrawStatusRequest
$request
)
public
function
withdraw
(
MusicianWithdrawStatusRequest
$request
,
WithdrawService
$withdrawService
)
{
return
$this
->
musicianWithdrawService
->
Withdraw
();
return
$this
->
musicianWithdrawService
->
Withdraw
(
$withdrawService
);
}
}
...
...
app/Models/Legal/StakeholderWithdrawAppLogs.php
0 → 100644
View file @
6957ea9
<?php
namespace
App\Models\Legal
;
use
App\Models\BaseModel
;
use
Illuminate\Support\Facades\DB
;
/**
* Class StakeholderWithdrawAppLogs
* @package App\Models\Legal
*/
class
StakeholderWithdrawAppLogs
extends
BaseModel
{
/**
* @var string
*/
protected
$table
=
'stakeholder_withdraw_app_logs'
;
/**
* @var array
*/
protected
$guarded
=
[];
}
app/Services/MusicianWithdrawService.php
View file @
6957ea9
...
...
@@ -114,9 +114,19 @@ class MusicianWithdrawService extends Service
* 修改提现状态
* @return \Illuminate\Http\JsonResponse|mixed
*/
public
function
withdraw
()
public
function
withdraw
(
WithdrawService
$withdrawService
)
{
if
(
!
$app
=
StakeholderIncomeSyncApp
::
query
()
->
where
([
'serial_no'
=>
$this
->
request
->
serial_no
,
'identifier'
=>
$this
->
identifier
->
identifier
,
'sync_status'
=>
1
,
])
->
first
())
{
return
Response
::
error
(
ErrorCode
::
WITHDRAW_NO_RECORD
);
}
return
call_user_func
([
$withdrawService
,
$this
->
request
->
type
],
$app
);
}
}
...
...
app/Services/WithdrawService.php
View file @
6957ea9
...
...
@@ -3,6 +3,13 @@
namespace
App\Services
;
use
App\ApiInterface\WithdrawInterface
;
use
App\Helper\ErrorCode
;
use
App\Helper\Response
;
use
App\Models\Legal\StakeholderBalanceByPayer
;
use
App\Models\Legal\StakeholderIncomeSyncApp
;
use
App\Models\Legal\StakeholderWithdrawAppLogs
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Log
;
/**
* Class MusicianAgreementService
...
...
@@ -12,29 +19,70 @@ class WithdrawService extends Service implements WithdrawInterface
{
/**
* 提现申请
* @param string $serial_no
* @return \Illuminate\Http\JsonResponse
* @param StakeholderIncomeSyncApp $app
*/
public
function
advance
(
string
$serial_no
)
public
function
advance
(
StakeholderIncomeSyncApp
$app
)
{
$condition
=
$this
->
compose
(
$app
);
DB
::
beginTransaction
();
try
{
//修改状态-》提现中
StakeholderIncomeSyncApp
::
query
()
->
where
([
'serial_no'
=>
$app
->
serial_no
,
'identifier'
=>
$this
->
identifier
->
identifier
,
'sync_status'
=>
1
,
'withdraw_status'
=>
1
])
->
update
([
'withdraw_status'
=>
2
]);
//修改资金账户
StakeholderBalanceByPayer
::
query
()
->
where
([
'condition'
=>
$condition
])
->
where
(
'balance'
,
'>='
,
$app
->
total_money
)
->
update
([
'freeze'
=>
DB
::
raw
(
"freeze +
{
$app
->
total_money
}
"
),
'balance'
=>
DB
::
raw
(
"balance -
{
$app
->
total_money
}
"
),
]);
//提现申请日志
StakeholderWithdrawAppLogs
::
query
()
->
create
([
'serial_no'
=>
$app
->
serial_no
,
'identifier'
=>
$this
->
identifier
->
identifier
,
'type'
=>
__FUNCTION__
,
'withdraw_money'
=>
$app
->
total_money
,
]);
DB
::
commit
();
return
Response
::
success
();
}
catch
(
\Exception
$e
)
{
DB
::
rollBack
();
Log
::
channel
(
'api'
)
->
error
(
__METHOD__
,
[
'msg'
=>
$e
->
getMessage
()]);
return
Response
::
error
(
ErrorCode
::
WITHDRAW_APPLY_FAIL
);
}
}
/**
* 提现成功
* @param
string $serial_no
* @param
StakeholderIncomeSyncApp $app
*/
public
function
success
(
string
$serial_no
)
public
function
success
(
StakeholderIncomeSyncApp
$app
)
{
// TODO: Implement success() method.
$condition
=
$this
->
compose
(
$app
);
}
/**
* 提现失败
* @param string $serial_no
* @param StakeholderIncomeSyncApp $app
*/
public
function
fail
(
StakeholderIncomeSyncApp
$app
)
{
$condition
=
$this
->
compose
(
$app
);
}
/**
* @param StakeholderIncomeSyncApp $app
* @return string
*/
p
ublic
function
fail
(
string
$serial_no
)
p
rivate
function
compose
(
StakeholderIncomeSyncApp
$app
)
{
// TODO: Implement fail() method.
return
$app
->
stakeholder_id
.
'|'
.
$app
->
subject_no
;
}
}
...
...
routes/api.php
View file @
6957ea9
...
...
@@ -40,7 +40,7 @@ Route::group([], function (){
//账单状态修改
Route
::
post
(
'withdraw/bill_confirm'
,
'MusicianWithdrawController@billConfirm'
);
//账单状态修改
Route
::
post
(
'withdraw/status'
,
'MusicianWithdrawController@withdraw'
);
Route
::
any
(
'withdraw/status'
,
'MusicianWithdrawController@withdraw'
);
//钱包-账单收益
Route
::
get
(
'wallet/detail'
,
'MusicianWalletController@walletDetail'
);
...
...
Please
register
or
sign in
to post a comment