Esempio n. 1
0
from user_app.redis.favorites_redis import favorites_redis
from user_app.redis.foot_redis import FootRedisOperation
from user_app.redis.shopcart_redis import ShopCartRedisOperation
from user_app.redis.user_redis import RedisUserOperation
from user_app.serializers.address_serializers import AddressSerializers
from user_app.serializers.bind_email_phone_serializers import BindPhoneOrEmailSerializer
from user_app.serializers.favorites_serializers import FavoritesSerializer
from user_app.serializers.foot_serializers import FootSerializer
from user_app.serializers.individual_info_serializers import IndividualInfoSerializer, HeadImageSerializer, \
    VerifyIdCardSerializer
from user_app.serializers.password_serializers import PasswordSerializer
from user_app.serializers.shopcart_serializers import ShopCartSerializer
from user_app.signals import add_favorites, delete_favorites
from user_app.utils.pagination import FootResultsSetPagination, FavoritesPagination, TrolleyResultsSetPagination

common_logger = Logging.logger('django')
consumer_logger = Logging.logger('consumer_')

User = get_user_model()


class HeadImageOperation(GenericAPIView):
    """
    修改头像
    """
    permission_classes = [IsAuthenticated]

    serializer_class = HeadImageSerializer

    storage_class = settings.DEFAULT_FILE_STORAGE
# -*- coding: utf-8 -*-
# @Time : 2020/6/1 23:31
# @Author : 司云中
# @File : seller_redis.py
# @Software: PyCharm

from Emall.base_redis import BaseRedis
from Emall.loggings import Logging

common_logger = Logging.logger('django')

shopper_logger = Logging.logger('shopper_')


class RedisShopperOperation(BaseRedis):
    """the operation of Shopper about redis"""
    def __init__(self, db, redis):
        super().__init__(db, redis)
Esempio n. 3
0
from rest_framework.decorators import action
from rest_framework.generics import GenericAPIView
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView

from order_app.utils.pagination import OrderResultsSetPagination
from order_app.models.order_models import Order_basic
from order_app.redis.order_redis import RedisOrderOperation
from order_app.serializers.order_serializers import OrderBasicSerializer, OrderCommoditySerializer, \
    OrderAddressSerializer, OrderCreateSerializer
from Emall.loggings import Logging

from Emall.response_code import response_code

common_logger = Logging.logger('django')

order_logger = Logging.logger('order_')


class OrderBasicOperation(viewsets.GenericViewSet):
    """订单基本操作"""

    # permission_classes = [IsAuthenticated]

    serializer_class = OrderBasicSerializer

    redis = RedisOrderOperation.choice_redis_db('redis')  # 选择redis具体db

    def get_queryset(self):
        """默认获取该用户的所有订单"""
Esempio n. 4
0
# -*- coding: utf-8 -*-
# @Time : 2020/5/29 13:29
# @Author : 司云中
# @File : user_marker_serializers.py
# @Software: PyCharm
import math

from remark_app.models.remark_models import Remark
from remark_app.signals import check_remark_action
from Emall.loggings import Logging
from rest_framework import serializers

common_logger = Logging.logger('django')

evaluate_logger = Logging.logger('evaluate_')


class ChoiceDisplayField(serializers.ChoiceField):
    def to_representation(self, value):
        """针对value(choice)转成我们需要的格式"""
        return self.choices[value]


class UserMarkerSerializer(serializers.ModelSerializer):
    GRADE_CHOICE = (
        (1, '一星好评'),
        (2, '二星好评'),
        (3, '三星好评'),
        (4, '四星好评'),
        (5, '五星好评'),
    )
Esempio n. 5
0
# -*- coding: utf-8 -*-
# @Time  : 2020/8/22 下午8:03
# @Author : 司云中
# @File : tasks.py
# @Software: Pycharm
import datetime

from Emall import celery_apps as app
from Emall.loggings import Logging
from analysis_app.utils.statistic_redis import statistic_redis

common_logger = Logging.logger('django')


@app.task
def statistic_login_times():
    """发送统计每日用户活跃量的定时信号"""
    date_str = datetime.date.strftime(datetime.date.today() - datetime.timedelta(1),'%Y-%m-%d')
    key = statistic_redis.key('login-day', date_str)
    pipe = statistic_redis.redis.pipeline()
    times = pipe.bitcount(key, 0,-1)    # 统计当天登录的用户次数
    pipe.delete(key)               # 删除bitmap
    pipe.set(key, times)      # 设置新key-value统计每日的用户
    pipe.execute()


@app.task
def statistic_buy_category_day():
    """
    每日统计购买商品的种类,获取前一天购买次数最多的商品种类
    清除前一天之前的所有记录(正常不需要清除,以防止不同步出问题)
Esempio n. 6
0
# -*- coding: utf-8 -*-
# @Time : 2020/6/2 14:22
# @Author : 司云中
# @File : shop_redis.py
# @Software: PyCharm
from shop_app.models.commodity_models import Commodity
from Emall.base_redis import BaseRedis
from Emall.loggings import Logging

common_logger = Logging.logger('django')

trolley_ = Logging.logger('trolley_')


class ShopRedisCartOperation(BaseRedis):
    """the operation of shop cart about redis,it means add goods into shop cart"""
    def __init__(self, db, redis):
        super().__init__(db, redis)

    @staticmethod
    def get_commodity(goods_id):
        """retrieve good instance based on good_id(index)"""
        try:
            commodity = Commodity.commodity_.get(pk=goods_id)
        except Commodity.DoesNotExist:
            return None
        else:
            return commodity

    def add_goods_into_shop_cart(self, user_id, **kwargs):
        """add new shop into shop_cart"""