Esempio n. 1
0
    def ordercount(self, request, *args, **kwargs):

        startdate = request.query_params.get('startdate', None)
        enddate = request.query_params.get('enddate', None)
        order = Order.objects.filter(umark=0)
        print(startdate, enddate)
        if startdate and enddate:
            startdate = string_toTimestamp(startdate)
            enddate = string_toTimestamp(enddate)
            order = order.filter(createtime__gte=startdate,
                                 createtime__lte=enddate)
        tgbzcount = 0
        jsbzcount = 0
        tgbztx = 0
        jsbztx = 0
        for item in order:
            if item.trantype == 0:
                tgbzcount += item.amount
                if item.status == 2:
                    tgbztx += item.amount
            else:
                jsbzcount += item.amount
                if item.status == 2:
                    jsbztx += item.amount

        return {
            'data': [{
                'tgbzcount': tgbzcount,
                'jsbzcount': jsbzcount,
                'tgbztx': tgbztx,
                'jsbztx': jsbztx
            }]
        }
Esempio n. 2
0
    def tranlistquery(self, request, *args, **kwargs):
        mobile = self.request.query_params.get('mobile', None)
        trantype = self.request.query_params.get('trantype', None)
        ordercode = self.request.query_params.get('ordercode', None)

        query_params = str()
        query_list = list()

        if mobile:
            query_params = "{} and t2.mobile=%s".format(query_params)
            query_list.append(mobile)
        if trantype:
            query_params = "{} and t1.trantype=%s".format(query_params)
            query_list.append(trantype)
        if ordercode:
            query_params = "{} and t1.ordercode=%s".format(query_params)
            query_list.append(ordercode)
        value2 = self.request.query_params.get('value2', None)
        if value2:
            query_params = "{} and t1.createtime>=%s and t1.createtime<=%s".format(
                query_params)
            query_list.append(string_toTimestamp(value2[:10] + ' 00:00:01'))
            query_list.append(string_toTimestamp(value2[:10] + ' 23:59:59'))

        tranlist = Tranlist.objects.raw(
            """
                   SELECT t1.id,t1.tranname,t2.mobile,t3.mobile as mobile_to,t1.amount,t1.bal,t1.createtime,t1.ordercode
                   FROM `tranlist` as t1
                   LEFT  JOIN `user` as t2 on t1.userid = t2.userid
                   LEFT  JOIN `user` as t3 on t1.userid_to = t3.userid
                   WHERE 1=1 {} order by t1.createtime DESC
               """.format(query_params), query_list)
        print(tranlist)

        return {'data': TranlistQuerySerializer(tranlist, many=True).data}
Esempio n. 3
0
    def orderquery(self, request, *args, **kwargs):
        status = self.request.query_params.get('status', None)
        ordercode = self.request.query_params.get('ordercode', None)
        mobile = self.request.query_params.get('mobile', None)
        ordercode_to = self.request.query_params.get('ordercode_to', None)
        mobile_to = self.request.query_params.get('mobile_to', None)

        if not status:
            raise PubErrorCustom("查询状态为空!")

        query_params = str()
        query_list = list()

        if status:
            query_params = "{} and t1.status=%s".format(query_params)
            query_list.append(status)
        if mobile:
            query_params = "{} and t2.mobile=%s".format(query_params)
            query_list.append(mobile)
        if ordercode:
            query_params = "{} and t1.ordercode=%s".format(query_params)
            query_list.append(ordercode)
        if mobile_to:
            query_params = "{} and t3.mobile=%s".format(query_params)
            query_list.append(mobile_to)
        if ordercode_to:
            query_params = "{} and t1.ordercode_to=%s".format(query_params)
            query_list.append(ordercode_to)

        value2 = self.request.query_params.get('value2', None)
        if value2:
            if str(status) == '1':
                query_params = "{} and t1.matchtime>=%s and t1.matchtime<=%s".format(
                    query_params)
            else:
                query_params = "{} and t1.confirmtime>=%s and t1.confirmtime<=%s".format(
                    query_params)
            query_list.append(string_toTimestamp(value2[:10] + ' 00:00:01'))
            query_list.append(string_toTimestamp(value2[:10] + ' 23:59:59'))

        print(query_params)
        print(query_list)

        order = Order.objects.raw(
            """
            SELECT t1.ordercode,t2.mobile,t3.mobile as mobile_to,t1.amount,t1.ordercode_to,t1.confirmtime,t1.img,t2.name,t3.name as name_to
            FROM `order` as t1
            INNER  JOIN `user` as t2 on t1.userid = t2.userid
            INNER  JOIN `user` as t3 on t1.userid_to = t3.userid
            WHERE t1.umark=0 and t1.trantype=0 {} order by t1.createtime DESC
        """.format(query_params), query_list)
        print(order)

        return {'data': OrderStatusSerializer(order, many=True).data}
Esempio n. 4
0
    def userquery(self,request, *args, **kwargs):

        username=self.request.query_params.get('username',None)
        name=self.request.query_params.get('name',None)
        referee_name=self.request.query_params.get('referee_name',None)
        matchauth=self.request.query_params.get('matchauth',None)
        startdate=self.request.query_params.get('startdate',None)
        enddate=self.request.query_params.get('enddate',None)


        userquery=Users.objects.all()
        if username:
            userquery=userquery.filter(username=username)
        if name:
            userquery=userquery.filter(name=name)
        if referee_name:
            userquery=userquery.filter(referee_name=referee_name)
        if matchauth:
            userquery = userquery.filter(matchauth=matchauth)
        if startdate and enddate:
            userquery = userquery.filter(createtime__gt=string_toTimestamp(startdate),createtime__lt=string_toTimestamp(enddate))

        return {'data':UsersSerializer(userquery.order_by('-createtime'),many=True).data}
Esempio n. 5
0
    def tgbzquery(self, request, *args, **kwargs):
        flag = self.request.query_params.get('flag', None)
        mobile = self.request.query_params.get('mobile', None)
        amount = self.request.query_params.get('amount', None)
        day = self.request.query_params.get('day', 2)
        ordercode = self.request.query_params.get('ordercode', None)
        value2 = self.request.query_params.get('value2', None)

        print(self.request.query_params)

        query_params = str()
        query_list = list()

        if mobile:
            query_params = "{} and t2.mobile=%s".format(query_params)
            query_list.append(mobile)
        if amount:
            query_params = "{} and t1.amount=%s".format(query_params)
            query_list.append(amount)
        if ordercode:
            query_params = "{} and t1.ordercode=%s".format(query_params)
            query_list.append(ordercode)
        if value2:
            query_params = "{} and t1.createtime>=%s and t1.createtime<=%s".format(
                query_params)
            query_list.append(string_toTimestamp(value2[:10] + ' 00:00:01'))
            query_list.append(string_toTimestamp(value2[:10] + ' 23:59:59'))

        print(query_params)
        print(query_list)

        order = Order.objects.raw(
            """
                SELECT t1.`ordercode`,t2.mobile,t1.amount,t2.name,t1.createtime,t1.status
                FROM `order` as t1
                INNER JOIN `user` as t2 ON t1.userid=t2.userid
                WHERE t1.ordercode not in (select ordercode from matchpool) and t1.status=0 and trantype=0 and t1.umark=0 {} ORDER BY createtime desc
            """.format(query_params), query_list)
        order = list(order)

        if flag:
            data = []
            order1 = Order.objects.raw("""
                    SELECT t1.ordercode,t1.userid,count(1) as count
                    FROM `order` as t1
                    INNER JOIN `user` as t2 ON t1.userid=t2.userid 
                    WHERE t1.ordercode not in (select ordercode from matchpool) and t1.status=0 and trantype=0 and t1.umark=0 group by t1.userid
                """)
            order1 = list(order1)
            if str(flag) == '1':
                for item in order:
                    isflag = False
                    for item1 in order1:
                        if item1.userid == item.userid and item1.count >= 5:
                            isflag = True
                    if isflag:
                        data.append(item)
            elif str(flag) == '2':
                for item in order:
                    isflag = False
                    for item1 in order1:
                        if item1.userid == item.userid and item1.count >= 3 and item1.count < 5:
                            isflag = True
                    if isflag:
                        data.append(item)
            elif str(flag) == '3':
                for item in order:
                    isflag = False
                    for item1 in order1:
                        if item1.userid == item.userid and item1.count < 3:
                            isflag = True
                    if isflag:
                        data.append(item)
            else:
                raise PubErrorCustom('isflag错误')

            order = data
        data = OrderSerializer1(order, many=True).data
        data1 = list()
        if day != '' and int(day) == 1:
            for item in data:
                if item['isday'] >= 5:
                    data1.append(item)
            data = data1
        return {'data': data}