提现申请
Showing
8 changed files
with
105 additions
and
18 deletions
| ... | @@ -2,15 +2,17 @@ | ... | @@ -2,15 +2,17 @@ |
| 2 | 2 | ||
| 3 | namespace App\ApiInterface; | 3 | namespace App\ApiInterface; |
| 4 | 4 | ||
| 5 | use App\Models\Legal\StakeholderIncomeSyncApp; | ||
| 6 | |||
| 5 | /** | 7 | /** |
| 6 | * Interface PaymentInterface | 8 | * Interface PaymentInterface |
| 7 | * @package App\ApiInterface | 9 | * @package App\ApiInterface |
| 8 | */ | 10 | */ |
| 9 | interface WithdrawInterface | 11 | interface WithdrawInterface |
| 10 | { | 12 | { |
| 11 | public function advance(string $serial_no); | 13 | public function advance(StakeholderIncomeSyncApp $app); |
| 12 | 14 | ||
| 13 | public function success(string $serial_no); | 15 | public function success(StakeholderIncomeSyncApp $app); |
| 14 | 16 | ||
| 15 | public function fail(string $serial_no); | 17 | public function fail(StakeholderIncomeSyncApp $app); |
| 16 | } | 18 | } | ... | ... |
| ... | @@ -126,8 +126,6 @@ class StakeholderIncomeSyncCommand extends Command | ... | @@ -126,8 +126,6 @@ class StakeholderIncomeSyncCommand extends Command |
| 126 | DB::rollBack(); | 126 | DB::rollBack(); |
| 127 | Log::channel('api')->error(__METHOD__, ['msg'=>$e->getMessage(), 'request'=>$request, 'response'=>$response]); | 127 | Log::channel('api')->error(__METHOD__, ['msg'=>$e->getMessage(), 'request'=>$request, 'response'=>$response]); |
| 128 | } | 128 | } |
| 129 | |||
| 130 | |||
| 131 | } | 129 | } |
| 132 | 130 | ||
| 133 | /** | 131 | /** | ... | ... |
| ... | @@ -20,6 +20,8 @@ class ErrorCode | ... | @@ -20,6 +20,8 @@ class ErrorCode |
| 20 | const WITHDRAW_NO_RECORD = 40051; | 20 | const WITHDRAW_NO_RECORD = 40051; |
| 21 | const WITHDRAW_HANDLE_ERROR = 40052; | 21 | const WITHDRAW_HANDLE_ERROR = 40052; |
| 22 | const WITHDRAW_CONFIRM_BILLS_FAIL = 40053; | 22 | const WITHDRAW_CONFIRM_BILLS_FAIL = 40053; |
| 23 | const WITHDRAW_APPLY_FAIL = 40054; | ||
| 24 | |||
| 23 | 25 | ||
| 24 | 26 | ||
| 25 | /** | 27 | /** |
| ... | @@ -39,6 +41,7 @@ class ErrorCode | ... | @@ -39,6 +41,7 @@ class ErrorCode |
| 39 | self::WITHDRAW_NO_RECORD => '未匹配有效提现记录', | 41 | self::WITHDRAW_NO_RECORD => '未匹配有效提现记录', |
| 40 | self::WITHDRAW_HANDLE_ERROR => '提现操作失败', | 42 | self::WITHDRAW_HANDLE_ERROR => '提现操作失败', |
| 41 | self::WITHDRAW_CONFIRM_BILLS_FAIL => '确认账单失败', | 43 | self::WITHDRAW_CONFIRM_BILLS_FAIL => '确认账单失败', |
| 44 | self::WITHDRAW_APPLY_FAIL => '提现申请失败', | ||
| 42 | ]; | 45 | ]; |
| 43 | 46 | ||
| 44 | 47 | ... | ... |
| ... | @@ -8,6 +8,7 @@ use App\Http\Requests\Musician\MusicianWithdrawReceiptByNameRequest; | ... | @@ -8,6 +8,7 @@ use App\Http\Requests\Musician\MusicianWithdrawReceiptByNameRequest; |
| 8 | use App\Http\Requests\Musician\MusicianWithdrawReceiptRequest; | 8 | use App\Http\Requests\Musician\MusicianWithdrawReceiptRequest; |
| 9 | use App\Http\Requests\Musician\MusicianWithdrawStatusRequest; | 9 | use App\Http\Requests\Musician\MusicianWithdrawStatusRequest; |
| 10 | use App\Services\MusicianWithdrawService; | 10 | use App\Services\MusicianWithdrawService; |
| 11 | use App\Services\WithdrawService; | ||
| 11 | 12 | ||
| 12 | /** | 13 | /** |
| 13 | * Class MusicianWithdrawController | 14 | * Class MusicianWithdrawController |
| ... | @@ -53,8 +54,8 @@ class MusicianWithdrawController extends Controller | ... | @@ -53,8 +54,8 @@ class MusicianWithdrawController extends Controller |
| 53 | * 提现状态修改 | 54 | * 提现状态修改 |
| 54 | * @return \Illuminate\Http\JsonResponse | 55 | * @return \Illuminate\Http\JsonResponse |
| 55 | */ | 56 | */ |
| 56 | public function withdraw(MusicianWithdrawStatusRequest $request) | 57 | public function withdraw(MusicianWithdrawStatusRequest $request, WithdrawService $withdrawService) |
| 57 | { | 58 | { |
| 58 | return $this->musicianWithdrawService->Withdraw(); | 59 | return $this->musicianWithdrawService->Withdraw($withdrawService); |
| 59 | } | 60 | } |
| 60 | } | 61 | } | ... | ... |
| 1 | <?php | ||
| 2 | |||
| 3 | namespace App\Models\Legal; | ||
| 4 | |||
| 5 | use App\Models\BaseModel; | ||
| 6 | use Illuminate\Support\Facades\DB; | ||
| 7 | |||
| 8 | /** | ||
| 9 | * Class StakeholderWithdrawAppLogs | ||
| 10 | * @package App\Models\Legal | ||
| 11 | */ | ||
| 12 | class StakeholderWithdrawAppLogs extends BaseModel | ||
| 13 | { | ||
| 14 | |||
| 15 | /** | ||
| 16 | * @var string | ||
| 17 | */ | ||
| 18 | protected $table = 'stakeholder_withdraw_app_logs'; | ||
| 19 | |||
| 20 | /** | ||
| 21 | * @var array | ||
| 22 | */ | ||
| 23 | protected $guarded = []; | ||
| 24 | |||
| 25 | } |
| ... | @@ -114,9 +114,19 @@ class MusicianWithdrawService extends Service | ... | @@ -114,9 +114,19 @@ class MusicianWithdrawService extends Service |
| 114 | * 修改提现状态 | 114 | * 修改提现状态 |
| 115 | * @return \Illuminate\Http\JsonResponse|mixed | 115 | * @return \Illuminate\Http\JsonResponse|mixed |
| 116 | */ | 116 | */ |
| 117 | public function withdraw() | 117 | public function withdraw(WithdrawService $withdrawService) |
| 118 | { | 118 | { |
| 119 | if (!$app = StakeholderIncomeSyncApp::query()->where([ | ||
| 120 | 'serial_no'=>$this->request->serial_no, | ||
| 121 | 'identifier'=>$this->identifier->identifier, | ||
| 122 | 'sync_status'=>1, | ||
| 123 | ]) | ||
| 124 | ->first()) { | ||
| 125 | |||
| 126 | return Response::error(ErrorCode::WITHDRAW_NO_RECORD); | ||
| 127 | } | ||
| 119 | 128 | ||
| 129 | return call_user_func([$withdrawService, $this->request->type], $app); | ||
| 120 | } | 130 | } |
| 121 | 131 | ||
| 122 | } | 132 | } | ... | ... |
| ... | @@ -3,6 +3,13 @@ | ... | @@ -3,6 +3,13 @@ |
| 3 | namespace App\Services; | 3 | namespace App\Services; |
| 4 | 4 | ||
| 5 | use App\ApiInterface\WithdrawInterface; | 5 | use App\ApiInterface\WithdrawInterface; |
| 6 | use App\Helper\ErrorCode; | ||
| 7 | use App\Helper\Response; | ||
| 8 | use App\Models\Legal\StakeholderBalanceByPayer; | ||
| 9 | use App\Models\Legal\StakeholderIncomeSyncApp; | ||
| 10 | use App\Models\Legal\StakeholderWithdrawAppLogs; | ||
| 11 | use Illuminate\Support\Facades\DB; | ||
| 12 | use Illuminate\Support\Facades\Log; | ||
| 6 | 13 | ||
| 7 | /** | 14 | /** |
| 8 | * Class MusicianAgreementService | 15 | * Class MusicianAgreementService |
| ... | @@ -12,29 +19,70 @@ class WithdrawService extends Service implements WithdrawInterface | ... | @@ -12,29 +19,70 @@ class WithdrawService extends Service implements WithdrawInterface |
| 12 | { | 19 | { |
| 13 | /** | 20 | /** |
| 14 | * 提现申请 | 21 | * 提现申请 |
| 15 | * @param string $serial_no | 22 | * @param StakeholderIncomeSyncApp $app |
| 16 | * @return \Illuminate\Http\JsonResponse | ||
| 17 | */ | 23 | */ |
| 18 | public function advance(string $serial_no) | 24 | public function advance(StakeholderIncomeSyncApp $app) |
| 19 | { | 25 | { |
| 26 | $condition = $this->compose($app); | ||
| 27 | |||
| 28 | DB::beginTransaction(); | ||
| 29 | |||
| 30 | try { | ||
| 31 | |||
| 32 | //修改状态-》提现中 | ||
| 33 | StakeholderIncomeSyncApp::query()->where(['serial_no'=>$app->serial_no, 'identifier'=>$this->identifier->identifier, 'sync_status'=>1, 'withdraw_status'=>1])->update([ | ||
| 34 | 'withdraw_status'=>2 | ||
| 35 | ]); | ||
| 36 | |||
| 37 | //修改资金账户 | ||
| 38 | StakeholderBalanceByPayer::query()->where(['condition'=>$condition])->where('balance', '>=', $app->total_money)->update([ | ||
| 39 | 'freeze' => DB::raw("freeze + {$app->total_money}"), | ||
| 40 | 'balance'=> DB::raw("balance - {$app->total_money}"), | ||
| 41 | ]); | ||
| 42 | |||
| 43 | //提现申请日志 | ||
| 44 | StakeholderWithdrawAppLogs::query()->create([ | ||
| 45 | 'serial_no' => $app->serial_no, | ||
| 46 | 'identifier' => $this->identifier->identifier, | ||
| 47 | 'type' => __FUNCTION__, | ||
| 48 | 'withdraw_money' => $app->total_money, | ||
| 49 | ]); | ||
| 50 | |||
| 51 | DB::commit(); | ||
| 52 | return Response::success(); | ||
| 53 | |||
| 54 | } catch (\Exception $e) { | ||
| 55 | DB::rollBack(); | ||
| 56 | Log::channel('api')->error(__METHOD__, ['msg'=>$e->getMessage()]); | ||
| 57 | return Response::error(ErrorCode::WITHDRAW_APPLY_FAIL); | ||
| 58 | } | ||
| 20 | 59 | ||
| 21 | } | 60 | } |
| 22 | 61 | ||
| 23 | /** | 62 | /** |
| 24 | * 提现成功 | 63 | * 提现成功 |
| 25 | * @param string $serial_no | 64 | * @param StakeholderIncomeSyncApp $app |
| 26 | */ | 65 | */ |
| 27 | public function success(string $serial_no) | 66 | public function success(StakeholderIncomeSyncApp $app) |
| 28 | { | 67 | { |
| 29 | // TODO: Implement success() method. | 68 | $condition = $this->compose($app); |
| 30 | } | 69 | } |
| 31 | 70 | ||
| 32 | /** | 71 | /** |
| 33 | * 提现失败 | 72 | * 提现失败 |
| 34 | * @param string $serial_no | 73 | * @param StakeholderIncomeSyncApp $app |
| 74 | */ | ||
| 75 | public function fail(StakeholderIncomeSyncApp $app) | ||
| 76 | { | ||
| 77 | $condition = $this->compose($app); | ||
| 78 | } | ||
| 79 | |||
| 80 | /** | ||
| 81 | * @param StakeholderIncomeSyncApp $app | ||
| 82 | * @return string | ||
| 35 | */ | 83 | */ |
| 36 | public function fail(string $serial_no) | 84 | private function compose(StakeholderIncomeSyncApp $app) |
| 37 | { | 85 | { |
| 38 | // TODO: Implement fail() method. | 86 | return $app->stakeholder_id .'|'. $app->subject_no; |
| 39 | } | 87 | } |
| 40 | } | 88 | } | ... | ... |
| ... | @@ -40,7 +40,7 @@ Route::group([], function (){ | ... | @@ -40,7 +40,7 @@ Route::group([], function (){ |
| 40 | //账单状态修改 | 40 | //账单状态修改 |
| 41 | Route::post('withdraw/bill_confirm', 'MusicianWithdrawController@billConfirm'); | 41 | Route::post('withdraw/bill_confirm', 'MusicianWithdrawController@billConfirm'); |
| 42 | //账单状态修改 | 42 | //账单状态修改 |
| 43 | Route::post('withdraw/status', 'MusicianWithdrawController@withdraw'); | 43 | Route::any('withdraw/status', 'MusicianWithdrawController@withdraw'); |
| 44 | //钱包-账单收益 | 44 | //钱包-账单收益 |
| 45 | Route::get('wallet/detail', 'MusicianWalletController@walletDetail'); | 45 | Route::get('wallet/detail', 'MusicianWalletController@walletDetail'); |
| 46 | 46 | ... | ... |
-
Please register or sign in to post a comment