How to design a set of integral system (with Django open source module)

Time:2022-1-15

The survey found that any app with background is inseparable from the point system, and even some apps are the point system itself! This article will focus on the open source integration framework vcoin, and how to use it

value system

As a personal developer or a company’s running product, it cannot do without the value system. The more direct point is the WeChat Alipay payment function, and the integral exchange of gifts, mainly for fission and marketing. If your product has no value system, it can only be realized by advertising, so the value system is very important.

What the hell is vcoin

Vcoin is a newly open source Django module, and the development language is Python; Directly use PIP install to complete the installation! The whole integration system is completely isolated from the business. When the upper business logic needs to add, delete, change, check, freeze and roll back the integration, it can directly call the static method of the integration system! If you have many apps or products, this set can be reused indefinitely!

Mode of use

=====
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'))
    #Token AES encryption for Base64
    VCoinManager.provideCoin(user_token=utoken, coin_count=10, coin_type=1)
    return HttpResponse(utoken)

Welcome to www.hehuoya.com com