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

  1. Add "vcoin" to your INSTALLED_APPS setting like this::

    INSTALLED_APPS = [
    ...
    'vcoin',
    ]

  2. 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)

  1. Run python3 manage.py makemigrations vcoin to create the vcoin models.

  2. Run python3 manage.py migrate to create the vcoin models.

  3. 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