Skip to content

Commit 1877fd9

Browse files
authored
Merge pull request #119 from bavix/discount
Attempt to introduce a discount system into the system
2 parents 158a9b7 + 6142983 commit 1877fd9

Some content is hidden

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

48 files changed

+1233
-149
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
use Bavix\Wallet\Models\Transfer;
4+
use Illuminate\Database\Migrations\Migration;
5+
use Illuminate\Database\Schema\Blueprint;
6+
use Illuminate\Support\Facades\Schema;
7+
8+
class AddDiscountTransfersTable extends Migration
9+
{
10+
11+
/**
12+
* @return string
13+
*/
14+
protected function table(): string
15+
{
16+
return (new Transfer())->getTable();
17+
}
18+
19+
/**
20+
* @return void
21+
*/
22+
public function up(): void
23+
{
24+
Schema::table($this->table(), function (Blueprint $table) {
25+
$table->bigInteger('discount')
26+
->default(0)
27+
->after('withdraw_id');
28+
});
29+
}
30+
31+
/**
32+
* @return void
33+
*/
34+
public function down(): void
35+
{
36+
Schema::table($this->table(), function (Blueprint $table) {
37+
$table->dropColumn('discount');
38+
});
39+
}
40+
41+
}

docs/basic-usage.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Item extends Model implements Product
6262
return true;
6363
}
6464

65-
public function getAmountProduct(): int
65+
public function getAmountProduct(Customer $customer): int
6666
{
6767
return 100;
6868
}
@@ -71,8 +71,7 @@ class Item extends Model implements Product
7171
{
7272
return [
7373
'title' => $this->title,
74-
'description' => 'Purchase of Product #' . $this->id,
75-
'price' => $this->getAmountProduct(),
74+
'description' => 'Purchase of Product #' . $this->id,
7675
];
7776
}
7877

docs/cart.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Item extends Model implements Product
3636
return true;
3737
}
3838

39-
public function getAmountProduct(): int
39+
public function getAmountProduct(Customer $customer): int
4040
{
4141
return round($this->price * 100);
4242
}
@@ -46,7 +46,6 @@ class Item extends Model implements Product
4646
return [
4747
'title' => $this->title,
4848
'description' => 'Purchase of Product #' . $this->getUniqueId(),
49-
'price' => $this->getAmountProduct(),
5049
];
5150
}
5251

docs/gift.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Item extends Model implements Product
3636
return true;
3737
}
3838

39-
public function getAmountProduct(): int
39+
public function getAmountProduct(Customer $customer): int
4040
{
4141
return 100;
4242
}
@@ -45,8 +45,7 @@ class Item extends Model implements Product
4545
{
4646
return [
4747
'title' => $this->title,
48-
'description' => 'Purchase of Product #' . $this->id,
49-
'price' => $this->getAmountProduct(),
48+
'description' => 'Purchase of Product #' . $this->id,
5049
];
5150
}
5251

@@ -75,7 +74,7 @@ Find the product.
7574

7675
```php
7776
$item = Item::first();
78-
$item->getAmountProduct(); // int(100)
77+
$item->getAmountProduct($first); // int(100)
7978
$item->balance; // int(0)
8079
```
8180

docs/pay-free.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Item extends Model implements Product
3636
return true;
3737
}
3838

39-
public function getAmountProduct(): int
39+
public function getAmountProduct(Customer $customer): int
4040
{
4141
return 100;
4242
}
@@ -45,8 +45,7 @@ class Item extends Model implements Product
4545
{
4646
return [
4747
'title' => $this->title,
48-
'description' => 'Purchase of Product #' . $this->id,
49-
'price' => $this->getAmountProduct(),
48+
'description' => 'Purchase of Product #' . $this->id,
5049
];
5150
}
5251

@@ -70,7 +69,7 @@ Find the goods and check the cost.
7069

7170
```php
7271
$item = Item::first();
73-
$item->getAmountProduct(); // int(100)
72+
$item->getAmountProduct($user); // int(100)
7473
$item->balance; // int(0)
7574
```
7675

docs/payment.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Item extends Model implements Product
3636
return true;
3737
}
3838

39-
public function getAmountProduct(): int
39+
public function getAmountProduct(Customer $customer): int
4040
{
4141
return 100;
4242
}
@@ -45,8 +45,7 @@ class Item extends Model implements Product
4545
{
4646
return [
4747
'title' => $this->title,
48-
'description' => 'Purchase of Product #' . $this->id,
49-
'price' => $this->getAmountProduct(),
48+
'description' => 'Purchase of Product #' . $this->id,
5049
];
5150
}
5251

@@ -70,7 +69,7 @@ Find the goods and check the cost.
7069

7170
```php
7271
$item = Item::first();
73-
$item->getAmountProduct(); // int(100)
72+
$item->getAmountProduct($user); // int(100)
7473
```
7574

7675
The user can buy a product, buy...

docs/refund.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Item extends Model implements Product
3636
return true;
3737
}
3838

39-
public function getAmountProduct(): int
39+
public function getAmountProduct(Customer $customer): int
4040
{
4141
return 100;
4242
}
@@ -45,8 +45,7 @@ class Item extends Model implements Product
4545
{
4646
return [
4747
'title' => $this->title,
48-
'description' => 'Purchase of Product #' . $this->id,
49-
'price' => $this->getAmountProduct(),
48+
'description' => 'Purchase of Product #' . $this->id,
5049
];
5150
}
5251

docs/ru/basic-usage.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Item extends Model implements Product
6565
return true;
6666
}
6767

68-
public function getAmountProduct(): int
68+
public function getAmountProduct(Customer $customer): int
6969
{
7070
return 100;
7171
}
@@ -74,8 +74,7 @@ class Item extends Model implements Product
7474
{
7575
return [
7676
'title' => $this->title,
77-
'description' => 'Purchase of Product #' . $this->id,
78-
'price' => $this->getAmountProduct(),
77+
'description' => 'Purchase of Product #' . $this->id,
7978
];
8079
}
8180
}

docs/ru/cart.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Item extends Model implements Product
3636
return true;
3737
}
3838

39-
public function getAmountProduct(): int
39+
public function getAmountProduct(Customer $customer): int
4040
{
4141
return round($this->price * 100);
4242
}
@@ -45,8 +45,7 @@ class Item extends Model implements Product
4545
{
4646
return [
4747
'title' => $this->title,
48-
'description' => 'Purchase of Product #' . $this->getUniqueId(),
49-
'price' => $this->getAmountProduct(),
48+
'description' => 'Purchase of Product #' . $this->getUniqueId(),
5049
];
5150
}
5251

docs/ru/gift.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Item extends Model implements Product
3636
return true;
3737
}
3838

39-
public function getAmountProduct(): int
39+
public function getAmountProduct(Customer $customer): int
4040
{
4141
return 100;
4242
}
@@ -45,8 +45,7 @@ class Item extends Model implements Product
4545
{
4646
return [
4747
'title' => $this->title,
48-
'description' => 'Purchase of Product #' . $this->id,
49-
'price' => $this->getAmountProduct(),
48+
'description' => 'Purchase of Product #' . $this->id,
5049
];
5150
}
5251

@@ -75,7 +74,7 @@ $last->balance; // int(0)
7574

7675
```php
7776
$item = Item::first();
78-
$item->getAmountProduct(); // int(100)
77+
$item->getAmountProduct($first); // int(100)
7978
$item->balance; // int(0)
8079
```
8180

0 commit comments

Comments
 (0)