Skip to content

3.0: new features #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rez1dent3 opened this issue Nov 29, 2018 · 11 comments
Closed

3.0: new features #18

rez1dent3 opened this issue Nov 29, 2018 · 11 comments
Assignees
Labels
help wanted Extra attention is needed question Further information is requested
Milestone

Comments

@rez1dent3
Copy link
Member

We write wishes that can be added to the project.

@zek
Copy link

zek commented Dec 1, 2018

Currency option like USD, EUR even Bitcoin would be cool.

@rez1dent3
Copy link
Member Author

@zek The wallet is not tied to a specific currency, this restriction falls on the developer. You can even use your own coins.

If you know how to implement your idea, please share.

@rez1dent3 rez1dent3 added help wanted Extra attention is needed question Further information is requested labels Dec 14, 2018
@rez1dent3 rez1dent3 self-assigned this Dec 14, 2018
@rez1dent3 rez1dent3 pinned this issue Dec 14, 2018
@rez1dent3
Copy link
Member Author

rez1dent3 commented May 13, 2019

  • you must log actions
  • to make an abbreviated syntax is more safe
  • remove the difference between $user->pay() and $user->wallet->pay()

@rez1dent3
Copy link
Member Author

rez1dent3 commented May 13, 2019

  • add ability to select by user
  • add purchase groups

@rez1dent3
Copy link
Member Author

@moecasts In branch 3.0.x-dev. Operation $user->pay($item) will be equivalent to operation $user->wallet->pay($item).

I advise you not to use abbreviated syntax now.

Therefore, in the Transfer model, the "from" column will be the wallet model.

@rez1dent3
Copy link
Member Author

rez1dent3 commented May 17, 2019

  • remove the ability to set the status of the transfer

@moecasts
Copy link
Contributor

@rez1dent3 I have create the new migration structures like that. I think that would be better.
The wallets table should not have name slug description columns, If you change the wallet name, you would change a lot of data. So, we can solve it by that If you want to name the wallet, you can set it to config/wallet.php like that.
And we can add from_wallet_id to_wallet_id action columns to the transfers table. Sometimes, a product has multi chargeable actions like read、download、subscribe. If there is a action column in transfers table, we can check the product was paid in the correct way.

<?php

return [
    ...
    'name' => [
    	'CNY' => '元',
    	'USD' => 'dollar'
    ];
    ...
];
Schema::create('wallets', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->morphs('holder');
    $table->string('currency')->default('CNY');
    $table->bigInteger('balance')->default(0);
    $table->timestamps();
});

Schema::create('transactions', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->morphs('holder');
    $table->bigIncrements('wallet_id');
    $table->enum('type', ['deposit', 'withdraw'])->index();
    $table->bigInteger('amount');
    $table->boolean('confirmed');
    $table->json('meta')->nullable();
    $table->uuid('uuid')->unique();
    $table->timestamps();
});

Schema::create('transfers', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->morphs('from');
    $table->unsignedInteger('from_wallet_id');
    $table->string('action')->comment('read/download/subscribe/trial and so on');
    $table->morphs('to');
    $table->unsignedInteger('to_wallet_id');
    $table->bigInteger('fee')->defalut(0);
    $table->unsignedInteger('deposit_id');
    $table->unsignedInteger('withdraw_id');
    $table->uuid('uuid')->unique();
    $table->timestamps();
});

@rez1dent3
Copy link
Member Author

rez1dent3 commented May 20, 2019

@moecasts I'll think about your structure. Thank you.

According to the changes in the table of wallets, I will not replace slug, name and description on currency. I am not tied to currencies and do not want to tie abstraction.

@rez1dent3
Copy link
Member Author

I'll borrow some ideas.

@moecasts
Copy link
Contributor

@rez1dent3 Actually, you can set currency to anything what you want, such as points, coins but not only currencies. I do not think that a currency need multi wallets.

@rez1dent3 rez1dent3 added this to the Ver3 milestone May 20, 2019
@rez1dent3
Copy link
Member Author

rez1dent3 commented May 22, 2019

@moecasts I've studied your structure and tested it against real data, it's good and bad at the same time. In the third version, the structure will not change. But I will fix bugs of the second version and strongly rewrite the code. I will take everything to the services and with singleton it will be possible to overload any part of the code.

PS, I care about the atomicity of data

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants