Skip to content

Commit 2928d31

Browse files
authored
Merge pull request #40 from bavix/3.0
3.0-Dev: Architecture correction
2 parents 56dae87 + e804d4b commit 2928d31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3658
-504
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ composer.phar
33
composer.lock
44
.idea/
55
build/
6+
.phpunit.result.cache
7+
.php_cs_cache

.phpstorm.meta.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace PHPSTORM_META {
4+
5+
use Bavix\Wallet\Models\Transaction;
6+
use Bavix\Wallet\Models\Transfer;
7+
use Bavix\Wallet\Models\Wallet;
8+
use Bavix\Wallet\Services\CommonService;
9+
use Bavix\Wallet\Services\ProxyService;
10+
use Bavix\Wallet\Services\WalletService;
11+
12+
override(\app(0), map([
13+
CommonService::class => CommonService::class,
14+
ProxyService::class => ProxyService::class,
15+
WalletService::class => WalletService::class,
16+
Wallet::class => Wallet::class,
17+
Transfer::class => Transfer::class,
18+
Transaction::class => Transaction::class,
19+
]));
20+
21+
}

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ build:
22

33
environment:
44
php:
5-
version: 7.1
5+
version: 7.2
66

77
nodes:
88
analysis:

README.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
laravel-wallet - Easy work with virtual wallet.
1515

16-
[[Documentation](https://laravel-wallet.bavix.ru/)]
17-
[[Get Started](https://laravel-wallet.bavix.ru/2.2/basic-usage)]
16+
[[Documentation](https://bavix.github.io/laravel-wallet/)]
17+
[[Get Started](https://bavix.github.io/laravel-wallet/#/basic-usage)]
1818

19-
[[Документация](https://laravel-wallet.bavix.ru/2.2-ru)]
20-
[[Как начать](https://laravel-wallet.bavix.ru/2.2-ru/basic-usage)]
19+
[[Документация](https://bavix.github.io/laravel-wallet/#/ru/)]
20+
[[Как начать](https://bavix.github.io/laravel-wallet/#/ru/basic-usage)]
2121

2222
* **Vendor**: bavix
2323
* **Package**: laravel-wallet
@@ -28,19 +28,7 @@ laravel-wallet - Easy work with virtual wallet.
2828

2929
### Upgrade Guide
3030

31-
To perform the migration, you will be [helped by the instruction](https://laravel-wallet.bavix.ru/2.2/upgrade-guide).
32-
33-
### Run Migrations
34-
Publish the migrations with this artisan command:
35-
```bash
36-
php artisan vendor:publish --tag=laravel-wallet-migrations
37-
```
38-
39-
### Configuration
40-
You can publish the config file with this artisan command:
41-
```bash
42-
php artisan vendor:publish --tag=laravel-wallet-config
43-
```
31+
To perform the migration, you will be [helped by the instruction](https://bavix.github.io/laravel-wallet/#/upgrade-guide).
4432

4533
### Usage
4634
Add the `HasWallet` trait and `Wallet` interface to model.
@@ -93,7 +81,7 @@ class Item extends Model implements Product
9381
{
9482
use HasWallet;
9583

96-
public function canBuy(Customer $customer, bool $force = false): bool
84+
public function canBuy(Customer $customer, int $quantity = 1, bool $force = null): bool
9785
{
9886
/**
9987
* If the service can be purchased once, then
@@ -115,6 +103,11 @@ class Item extends Model implements Product
115103
'price' => $this->getAmountProduct(),
116104
];
117105
}
106+
107+
public function getUniqueId(): string
108+
{
109+
return (string)$this->getKey();
110+
}
118111
}
119112
```
120113

changelog.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,48 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- Add service `CommonService`
10+
- Add service `ProxyService`
11+
- Add service `WalletService`
12+
- Add object Bring (simple transfer)
13+
- Add object Operation (simple transaction)
14+
- Add feature Cart (multi pay + quantity)
15+
- Add method `payFreeCart`
16+
- Add method `safePayCart`
17+
- Add method `payCart`
18+
- Add method `forcePayCart`
19+
- Add method `safeRefundCart`
20+
- Add method `refundCart`
21+
- Add method `forceRefundCart`
22+
- Add method `safeRefundGiftCart`
23+
- Add method `refundGiftCart`
24+
- Add method `forceRefundGiftCart`
25+
- Add method `getUniqueId` to Interface `Product`
26+
27+
### Changed
28+
- applied fixes from cs-fixer
29+
- change singleton path `bavix.wallet::transaction` to `Bavix\Wallet\Models\Transaction::class`
30+
- change singleton path `bavix.wallet::transfer` to `Bavix\Wallet\Models\Transfer::class`
31+
- change singleton path `bavix.wallet::wallet` to `Bavix\Wallet\Models\Wallet::class`
32+
- change method `canBuy`. Added parameter `$quantity`
33+
34+
### Removed
35+
- method `calculateBalance`.
36+
- method `holderTransfers`.
37+
- attribute `$status` from Interfaces/Wallet::transfer
38+
- attribute `$status` from Interfaces/Wallet::safeTransfer
39+
- attribute `$status` from Interfaces/Wallet::forceTransfer
40+
- attribute `$status` from Interfaces/WalletFloat::transfer
41+
- attribute `$status` from Interfaces/WalletFloat::safeTransfer
42+
- attribute `$status` from Interfaces/WalletFloat::forceTransfer
43+
- class `Tax`
44+
- class `WalletProxy`
45+
- protected method `checkAmount`
46+
- protected method `assemble`
47+
- protected method `change`
48+
- protected method `holderTransfers`
49+
- protected method `addBalance`
850

951
## [2.4.1] - 2019-05-17
1052
### Fixed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
"require": {
2626
"php": "^7.1",
2727
"illuminate/database": "~5.5.0|~5.6.0|~5.7.0|~5.8.0",
28+
"nesbot/carbon": "^1.20|^2.0",
2829
"doctrine/dbal": "^2.8",
2930
"ramsey/uuid": "^3.0"
3031
},
3132
"require-dev": {
32-
"mockery/mockery": "^1.2",
3333
"orchestra/testbench": "^3.7",
34-
"phpunit/phpunit": "^7.5"
34+
"phpstan/phpstan": "^0.11.7",
35+
"phpunit/phpunit": "^7.5|^8.1"
3536
},
3637
"autoload": {
3738
"psr-4": {

config/config.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
'package' => [
55
'coefficient' => 100.,
66
],
7+
'services' => [
8+
'common' => \Bavix\Wallet\Services\CommonService::class,
9+
'proxy' => \Bavix\Wallet\Services\ProxyService::class,
10+
'wallet' => \Bavix\Wallet\Services\WalletService::class,
11+
],
712
'transaction' => [
813
'table' => 'transactions',
914
'model' => \Bavix\Wallet\Models\Transaction::class,

database/migrations_v2/2018_11_15_124230_create_wallets_table.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Bavix\Wallet\Models\Transaction;
44
use Bavix\Wallet\Models\Wallet;
5+
use Carbon\Carbon;
56
use Illuminate\Database\Eloquent\Collection;
67
use Illuminate\Database\Migrations\Migration;
78
use Illuminate\Database\Schema\Blueprint;
@@ -47,8 +48,8 @@ public function up(): void
4748
->selectRaw('? as name', [$default])
4849
->selectRaw('? as slug', [$slug])
4950
->selectRaw('sum(amount) as balance')
50-
->selectRaw('? as created_at', [\Carbon\Carbon::now()])
51-
->selectRaw('? as updated_at', [\Carbon\Carbon::now()])
51+
->selectRaw('? as created_at', [Carbon::now()])
52+
->selectRaw('? as updated_at', [Carbon::now()])
5253
->groupBy('holder_type', 'holder_id')
5354
->orderBy('holder_type');
5455

database/migrations_v2/2019_05_13_111553_update_status_transfers_table.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
use Bavix\Wallet\Models\Transfer;
44
use Illuminate\Database\Migrations\Migration;
5+
use Illuminate\Database\MySqlConnection;
6+
use Illuminate\Database\PostgresConnection;
57
use Illuminate\Database\Schema\Blueprint;
68
use Illuminate\Support\Facades\DB;
79
use Illuminate\Support\Facades\Schema;
@@ -29,16 +31,16 @@ public function up(): void
2931
Transfer::STATUS_GIFT,
3032
];
3133

32-
if (DB::connection() instanceof \Illuminate\Database\MySqlConnection) {
34+
if (DB::connection() instanceof MySqlConnection) {
3335
$table = $this->table();
34-
$enumString = \implode('\', \'', $enums);
36+
$enumString = implode('\', \'', $enums);
3537
$default = Transfer::STATUS_TRANSFER;
3638
DB::statement("ALTER TABLE $table CHANGE COLUMN status status ENUM('$enumString') NOT NULL DEFAULT '$default'");
3739
DB::statement("ALTER TABLE $table CHANGE COLUMN status_last status_last ENUM('$enumString') NULL");
3840
return;
3941
}
4042

41-
if (DB::connection() instanceof \Illuminate\Database\PostgresConnection) {
43+
if (DB::connection() instanceof PostgresConnection) {
4244
$this->alterEnum($this->table(), 'status', $enums);
4345
$this->alterEnum($this->table(), 'status_last', $enums);
4446
return;
@@ -74,16 +76,16 @@ public function down(): void
7476
Transfer::STATUS_GIFT,
7577
];
7678

77-
if (DB::connection() instanceof \Illuminate\Database\MySqlConnection) {
79+
if (DB::connection() instanceof MySqlConnection) {
7880
$table = $this->table();
79-
$enumString = \implode('\', \'', $enums);
81+
$enumString = implode('\', \'', $enums);
8082
$default = Transfer::STATUS_PAID;
8183
DB::statement("ALTER TABLE $table CHANGE COLUMN status status ENUM('$enumString') NOT NULL DEFAULT '$default'");
8284
DB::statement("ALTER TABLE $table CHANGE COLUMN status_last status_last ENUM('$enumString') NULL");
8385
return;
8486
}
8587

86-
if (DB::connection() instanceof \Illuminate\Database\PostgresConnection) {
88+
if (DB::connection() instanceof PostgresConnection) {
8789
$this->alterEnum($this->table(), 'status', $enums);
8890
$this->alterEnum($this->table(), 'status_last', $enums);
8991
return;
@@ -112,7 +114,7 @@ protected function alterEnum($table, $field, array $options): void
112114

113115
$enumList = [];
114116

115-
foreach($options as $option) {
117+
foreach ($options as $option) {
116118
$enumList[] = sprintf("'%s'::CHARACTER VARYING", $option);
117119
}
118120

docs/.nojekyll

Whitespace-only changes.

0 commit comments

Comments
 (0)