调研发现任何一款有背景的 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