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
8db02e59
...
8db02e598cd936e7dab794a1a7539bf1eabb316c
authored
2021-11-14 21:29:58 +0800
by
lemon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
分贝确认账单接口
1 parent
88c3776f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
182 additions
and
36 deletions
app/Helper/CacheKeyTools.php
app/Helper/ErrorCode.php
app/Http/Controllers/Musician/MusicianWithdrawController.php
app/Http/Requests/Musician/MusicianWithdrawBillConfirmRequest.php
app/Models/Legal/StakeholderPrepaid.php
app/Services/MusicianWithdrawService.php
config/cache.php
app/Helper/CacheKeyTools.php
View file @
8db02e5
...
...
@@ -26,4 +26,12 @@ class CacheKeyTools
return
config
(
'cache.key'
)[
'channelname'
];
}
/**
* @return mixed
*/
public
static
function
billsConfirm
(
$busi_id
)
{
return
str_replace
(
'#busi_id#'
,
$busi_id
,
config
(
'cache.key'
)[
'bills_confirm'
]);
}
}
...
...
app/Helper/ErrorCode.php
View file @
8db02e5
...
...
@@ -7,36 +7,38 @@ namespace App\Helper;
*/
class
ErrorCode
{
const
SERVER_ERROR
=
-
1
;
const
SERVER_OK
=
0
;
const
IDENTIFIER_FAIL
=
40001
;
const
MATCH_IDENTIFIER_FAIL
=
40002
;
const
REPEAT_SUBMIT
=
40003
;
const
ILLEGAL_PARAMS
=
40035
;
const
ORDER_ILLEGAl
=
40040
;
const
ORDER_WITHDRAW_ERROR
=
40041
;
const
ORDER_MONEY_ERROR
=
40042
;
const
ORDER_NO_FOUND
=
40043
;
const
WITHDRAW_NO_RECORD
=
40051
;
const
WITHDRAW_HANDLE_ERROR
=
40052
;
const
SERVER_ERROR
=
-
1
;
const
SERVER_OK
=
0
;
const
IDENTIFIER_FAIL
=
40001
;
const
MATCH_IDENTIFIER_FAIL
=
40002
;
const
REPEAT_SUBMIT
=
40003
;
const
ILLEGAL_PARAMS
=
40035
;
const
ORDER_ILLEGAl
=
40040
;
const
ORDER_WITHDRAW_ERROR
=
40041
;
const
ORDER_MONEY_ERROR
=
40042
;
const
ORDER_NO_FOUND
=
40043
;
const
WITHDRAW_NO_RECORD
=
40051
;
const
WITHDRAW_HANDLE_ERROR
=
40052
;
const
WITHDRAW_CONFIRM_BILLS_FAIL
=
40053
;
/**
* @var string[]
*/
public
static
$messages
=
[
self
::
SERVER_ERROR
=>
'服务器繁忙'
,
self
::
MATCH_IDENTIFIER_FAIL
=>
'匹配身份失败'
,
self
::
REPEAT_SUBMIT
=>
'请勿重复提交'
,
self
::
SERVER_OK
=>
'成功'
,
self
::
IDENTIFIER_FAIL
=>
'身份验证失败'
,
self
::
ILLEGAL_PARAMS
=>
'不合法的参数'
,
self
::
ORDER_ILLEGAl
=>
'提现订单有误'
,
self
::
ORDER_WITHDRAW_ERROR
=>
'提现记录有误'
,
self
::
ORDER_MONEY_ERROR
=>
'提现金额有误'
,
self
::
ORDER_NO_FOUND
=>
'未找到订单记录'
,
self
::
WITHDRAW_NO_RECORD
=>
'未匹配有效提现记录'
,
self
::
WITHDRAW_HANDLE_ERROR
=>
'提现操作失败'
,
self
::
SERVER_ERROR
=>
'服务器繁忙'
,
self
::
MATCH_IDENTIFIER_FAIL
=>
'匹配身份失败'
,
self
::
REPEAT_SUBMIT
=>
'请勿重复提交'
,
self
::
SERVER_OK
=>
'成功'
,
self
::
IDENTIFIER_FAIL
=>
'身份验证失败'
,
self
::
ILLEGAL_PARAMS
=>
'不合法的参数'
,
self
::
ORDER_ILLEGAl
=>
'提现订单有误'
,
self
::
ORDER_WITHDRAW_ERROR
=>
'提现记录有误'
,
self
::
ORDER_MONEY_ERROR
=>
'提现金额有误'
,
self
::
ORDER_NO_FOUND
=>
'未找到订单记录'
,
self
::
WITHDRAW_NO_RECORD
=>
'未匹配有效提现记录'
,
self
::
WITHDRAW_HANDLE_ERROR
=>
'提现操作失败'
,
self
::
WITHDRAW_CONFIRM_BILLS_FAIL
=>
'确认账单失败'
,
];
...
...
app/Http/Controllers/Musician/MusicianWithdrawController.php
View file @
8db02e5
...
...
@@ -3,6 +3,7 @@
namespace
App\Http\Controllers\Musician
;
use
App\Http\Controllers\Controller
;
use
App\Http\Requests\Musician\MusicianWithdrawBillConfirmRequest
;
use
App\Http\Requests\Musician\MusicianWithdrawReceiptByNameRequest
;
use
App\Http\Requests\Musician\MusicianWithdrawReceiptRequest
;
use
App\Http\Requests\Musician\MusicianWithdrawStatusRequest
;
...
...
@@ -29,26 +30,25 @@ class MusicianWithdrawController extends Controller
}
/**
* 发票信息
* @param MusicianWithdrawReceiptRequest $request
*
通过公司名称查询
发票信息
* @param MusicianWithdrawReceipt
ByName
Request $request
* @return \Illuminate\Http\JsonResponse
*/
public
function
receipt
(
MusicianWithdrawReceipt
Request
$request
)
public
function
receipt
ByName
(
MusicianWithdrawReceiptByName
Request
$request
)
{
return
$this
->
musicianWithdrawService
->
receiptInfo
();
return
$this
->
musicianWithdrawService
->
receiptInfo
ByName
();
}
/**
*
通过公司名称查询发票信息
* @param MusicianWithdraw
ReceiptByName
Request $request
*
账单确认
* @param MusicianWithdraw
BillConfirm
Request $request
* @return \Illuminate\Http\JsonResponse
*/
public
function
receiptByName
(
MusicianWithdrawReceiptByName
Request
$request
)
public
function
billConfirm
(
MusicianWithdrawBillConfirm
Request
$request
)
{
return
$this
->
musicianWithdrawService
->
receiptInfoByName
();
return
$this
->
musicianWithdrawService
->
billConfirm
();
}
/**
* 提现修改状态
* @return \Illuminate\Http\JsonResponse
...
...
app/Http/Requests/Musician/MusicianWithdrawBillConfirmRequest.php
0 → 100644
View file @
8db02e5
<?php
namespace
App\Http\Requests\Musician
;
use
Illuminate\Foundation\Http\FormRequest
;
/**
* Class MusicianWithdrawBillConfirmRequest
* @package App\Http\Requests\Musician
*/
class
MusicianWithdrawBillConfirmRequest
extends
FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public
function
authorize
()
{
return
true
;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public
function
rules
()
{
return
[
'busi_id'
=>
[
'required'
,
'bail'
],
];
}
/**
* @return string[]
*/
public
function
messages
()
:
array
{
return
[
'busi_id.required'
=>
'请提供分贝订单流水号'
,
];
}
}
app/Models/Legal/StakeholderPrepaid.php
0 → 100644
View file @
8db02e5
<?php
namespace
App\Models\Legal
;
use
App\Models\BaseModel
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
/**
* Class StakeholderBalance
* @package App\Models\Legal
*/
class
StakeholderPrepaid
extends
BaseModel
{
use
HasFactory
;
/**
* @var string
*/
protected
$table
=
'stakeholder_prepaid'
;
}
app/Services/MusicianWithdrawService.php
View file @
8db02e5
...
...
@@ -2,13 +2,20 @@
namespace
App\Services
;
use
App\Helper\CacheKeyTools
;
use
App\Helper\ErrorCode
;
use
App\Helper\RedisClient
;
use
App\Helper\Response
;
use
App\Models\Legal\Company
;
use
App\Models\Legal\Contract
;
use
App\Models\Legal\StakeholderIncomeByPayer
;
use
App\Models\Legal\StakeholderBalanceByPayer
;
use
App\Models\Legal\StakeholderBalanceDetail
;
use
App\Models\Legal\StakeholderIncomeSyncApp
;
use
App\Models\Legal\StakeholderIncomeSyncAppDetails
;
use
App\Models\Legal\StakeholderPrepaid
;
use
App\Models\Legal\StakeholderSongCollate
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Log
;
/**
* Class MusicianAgreementService
...
...
@@ -97,4 +104,68 @@ class MusicianWithdrawService extends Service
}
}
/**
* 确认账单
* @return \Illuminate\Http\JsonResponse
*/
public
function
billConfirm
()
{
if
(
RedisClient
::
instance
(
'bills'
)
->
set
(
CacheKeyTools
::
billsConfirm
(
$this
->
request
->
busi_id
),
true
,
'EX'
,
3
,
'NX'
))
{
$app
=
StakeholderIncomeSyncApp
::
query
()
->
where
([
'busi_id'
=>
$this
->
request
->
busi_id
,
'sync_status'
=>
0
])
->
select
([
'id'
,
'subject_no'
,
'company_id'
,
'stakeholder_id'
,
'related_id'
])
->
first
();
DB
::
beginTransaction
();
try
{
if
(
empty
(
$app
))
throw
new
\Exception
(
'找不到同步到分贝收益记录'
);
$condition
=
"
{
$app
->
stakeholder_id
}
|
{
$app
->
subject_no
}
"
;
$balance_detail
=
StakeholderBalanceDetail
::
query
()
->
where
([
'status'
=>
0
,
'company_id'
=>
$app
->
company_id
,
'stakeholder_id'
=>
$app
->
stakeholder_id
,
'bills_id'
=>
$app
->
related_id
,
'subject_no'
=>
$app
->
subject_no
])
->
first
();
if
(
empty
(
$app
))
throw
new
\Exception
(
'找不到相关入账记录'
);
//权益人-付款主体账户
StakeholderBalanceByPayer
::
query
()
->
where
([
'condition'
=>
$condition
])
->
update
([
'account'
=>
DB
::
raw
(
"account +
{
$balance_detail
->
real_share_amount
}
"
),
//总收入
'balance'
=>
DB
::
raw
(
"balance +
{
$balance_detail
->
real_share_amount
}
"
),
//剩余提现余额
'confirmed_amount'
=>
DB
::
raw
(
"confirmed_amount -
{
$balance_detail
->
real_share_amount
}
"
),
//待确认收益
'deduct_prepaid'
=>
DB
::
raw
(
"deduct_prepaid +
{
$balance_detail
->
deduct_prepaid
}
"
),
//核销预付
'freeze_prepaid'
=>
DB
::
raw
(
"freeze_prepaid -
{
$balance_detail
->
deduct_prepaid
}
"
),
//冻结预付
]);
//权益人-付款主体预付账本
if
(
!
empty
(
$balance_detail
[
'prepaid_detail'
]))
{
foreach
(
$balance_detail
[
'prepaid_detail'
]
as
$prepaid
=>
$prepaid_detail
)
{
StakeholderPrepaid
::
query
()
->
where
([
'id'
=>
$prepaid
])
->
update
([
'freeze_prepaid'
=>
DB
::
raw
(
"freeze_prepaid -
{
$prepaid_detail
[
'freeze_prepaid'
]
}
"
),
'deduct_prepaid'
=>
DB
::
raw
(
"deduct_prepaid +
{
$prepaid_detail
[
'freeze_prepaid'
]
}
"
),
]);
}
}
//改变状态 - 已入账
StakeholderBalanceDetail
::
query
()
->
where
([
'id'
=>
$balance_detail
->
id
,
'status'
=>
0
])
->
update
([
'status'
=>
1
]);
//更新同步分贝记录
StakeholderIncomeSyncApp
::
query
()
->
where
([
'id'
=>
$app
->
id
,
'withdraw_status'
=>
0
])
->
update
([
'withdraw_status'
=>
1
,
]);
DB
::
commit
();
return
Response
::
success
();
}
catch
(
\Exception
$e
)
{
DB
::
rollBack
();
Log
::
info
(
__METHOD__
.
':确认账单失败'
,
[
'msg'
=>
$e
->
getMessage
(),
'params'
=>
$this
->
request
->
all
()]);
return
Response
::
error
(
ErrorCode
::
WITHDRAW_CONFIRM_BILLS_FAIL
);
}
}
else
{
return
Response
::
error
(
ErrorCode
::
REPEAT_SUBMIT
);
}
}
}
...
...
config/cache.php
View file @
8db02e5
...
...
@@ -109,8 +109,9 @@ return [
//cache_key
'key'
=>
[
'bills_sync'
=>
'bills:sync'
,
'channelname'
=>
'channelname'
,
'bills_sync'
=>
'bills:sync'
,
'channelname'
=>
'channelname'
,
'bills_confirm'
=>
'busid:#busi_id#'
,
]
];
...
...
Please
register
or
sign in
to post a comment