調研發現任何一款有背景的app都離不開積分系統,甚至有的app本身就是積分系統!本文將重點介紹開源積分框架vcoin,以及使用方式
價值體系
作為個人開發者或者公司運營的產品,都離不開價值體系,更直接一點的就是微信支付寶支付功能,還有積分兌換禮品,主要為了裂變和營銷,如果你的產品中沒有價值體系,只能靠廣告變現了,所以價值體系很重要
vcoin是個什么鬼
vcoin是最近剛開源的django模塊,開發語言是python;直接使用pip install就可以完成安裝使用!整個積分系統與業務完全隔離,上層業務邏輯在需要積分的增刪改查凍結回退等操作的時候,直接調用積分系統靜態方法即可!如果你有很多app或者產品,這一套是可以無限復用的!
使用方式
=====
django-vcoin
=====
django-vcoin project is coin application for hehuoya.com
virtual coin for app
Quick start
-
Add "vcoin" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
...
'vcoin',
] -
Include the class in your project views.py like this::
from vcoin.Checker import HHYAES
from vcoin.views import VCoinManager
and then pass your user token for vcoin
aes_encrypt_data = HHYAES.aes_encrypt(utoken.decode(encoding='utf-8'))
utoken = base64.b64encode(aes_encrypt_data.encode('utf-8'))
VCoinManager.freezeCoin(utoken, 50, 1)
-
Run
python3 manage.py makemigrations vcoin
to create the vcoin models. -
Run
python3 manage.py migrate
to create the vcoin models. -
Start the development server and visit http://127.0.0.1:8000/admin/
to create a models if needed (you'll need the Admin app enabled).
demo:
from vcoin.Checker import HHYAES
from vcoin.views import VCoinManager
def index(request):
current_milli_time = int(round(time.time() * 1000))
utoken = ('AABBB>' + str(current_milli_time)).encode("utf-8")
aes_encrypt_data = HHYAES.aes_encrypt(utoken.decode(encoding='utf-8'))
utoken = base64.b64encode(aes_encrypt_data.encode('utf-8'))
# 對base64的tokenAES加密
VCoinManager.provideCoin(user_token=utoken, coin_count=10, coin_type=1)
return HttpResponse(utoken)
歡迎關注 www.hehuoya.com